Methods

Learn to create and call methods in .NET apps.

We'll cover the following...

Create methods

A variable is a named area of memory that holds a value of some type. The methods are similar, but instead of holding a value, methods are named blocks of instructions.

The basic syntax for creating a method is as follows:

[modifiers] return_type method_name([parameters])
{
	// Method body
}

Note: Modifiers (not covered in this lesson) and parameters are optional.

We’ve already addressed methods. Apart from the WriteLine() method of the Console class we’ve been using to print to the console, we’ve created one method that’s mandatory in all .NET programs:

static void Main(string[]
...