Defining a method properly

Just like for variables, we have to let Unity know about a method before we can use it.

Depending on who you talk to, some will say we have to declare a method, others will say we have to define a method. Which is correct? In C#, it doesn't make any difference. Use which ever term helps you learn easier. I like to say I'm defining a method's code block, nothing like declaring a simple variable on a one line statement.

The minimum requirements for defining a method

There are three minimum requirements for defining a method:

  • The type of information, or data, a method will return to the place where the method was called
  • The name of the method should be followed by a pair of parentheses
  • A pair of curly braces should be present ...

Get Learning C# by Developing Games with Unity 3D Beginner's Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.