Hello World

The Main Method

 Here is the "Hello World" program. Feel free to play with it as we discuss the code.

using System; public class Program { ...

 

By default, C# will try and execute a method called Main as the starting point of the application. This is known as the application Entry Point. For more information about the Entry Point, see the "Deep Dive" section of this tutorial.

We can define a class, named Program as follows:

using System;

public class Program
{

}

 

Notice that C# uses brackets, { and } to indicate blocks of code. Now let's add our Main method.

using System;

public class Program
{
    public static void Main()
    {

    }
}

Don't worry about the public static void part for now, we'll cover that in later sections.

 

Useful Tip

If you want to play with the code in an example of exercise in a separate browser window, you can either open another copy of the page that contains it, or open .NET Fiddle in a separate window. You can copy and paste the code into .NET Fiddle.
 

 

 

Page 2 of 13