In the previous chapter, you were introduced to a variable's scope, within which a variable exists and is allowed to be used. The scope is determined by the opening and closing curly brackets. The purpose of those curly brackets is to act as a container for a block of executable code, a code block. In the second chapter, you understood that a method is a code block that can execute by just calling the method's name. It's time to understand the importance of code blocks and the variables used in them. A method defines a code block that begins and ends with curly brackets.
In this chapter, we will cover the following topics:
- Using methods in a script
- Naming methods the good way
- Defining a method
- Calling a method
- Returning a value from a method
Variables are the first major building block of C# and methods are the second, so let...