As with variables, method declarations have their basic requirements, which are as follows:
- The type of data that will be returned by the method
- A unique name, starting with a capital letter
- A pair of parentheses following the method name
- A pair of curly brackets marking the method body (where instructions are stored)
Putting all of these rules together, we get a simple method blueprint:
returnType UniqueName()
{
method body
}
Let's break down the default Start() method in LearningCurve as a practical example:
In the preceding output, we can see the following:
- The method starts with the void keyword, which is used as the method's return type if it doesn't return any data.
- The method has a unique name.
- The method has a pair of parentheses after its name to hold any potential parameters.
- The method body is defined by a set of curly brackets.
In general, if you have a method that has an empty method body, it's good practice...