- Learning C# by Developing Games with Unity 3D Beginner's Guide
- Terry Norton
- 156字
- 2021-08-04 10:04:03
Returning a value from a method
Now it's time to discover the "power" feature of using a method. This usually means sending data to the method, which you just learned to do, then have the method return a value back. Previously, all you had the AddTwoNumbers()
method do was take the result of adding two numbers and display it to Unity's Console.
Now, instead of displaying the result directly, you're going to modify AddTwoNumbers()
to return the result of the addition back to the place the method was called.
Note
Remember, I told you that when you call a method, it's just a substitute for the code block that will be executed. It's like taking all the code in the method's code block and placing it right there where the method was called.
The next screenshot is still very simple, but it shows how this substitution works and how returning a value from a method works.
- Getting Started with Citrix XenApp? 7.6
- 神經網絡編程實戰:Java語言實現(原書第2版)
- 小程序,巧運營:微信小程序運營招式大全
- Mastering openFrameworks:Creative Coding Demystified
- Visual Studio Code 權威指南
- Django 5企業級Web應用開發實戰(視頻教學版)
- Learning VMware vSphere
- Arduino Wearable Projects
- Robot Framework Test Automation
- 和孩子一起學編程:用Scratch玩Minecraft我的世界
- 現代C++語言核心特性解析
- 信息學奧林匹克競賽初賽精講精練
- 循序漸進Vue.js 3前端開發實戰
- VMware vRealize Orchestrator Essentials
- Mastering VMware vSphere Storage