Hello World in C#

Main Method

 
	public static void Main()
	{
		Console.WriteLine("Hello World");
	}

The method "Main" has public access modifier which means that this method can be called by other classes and even other assemblies.  

Access modifier is followed by static, which is a modifier that allows this function to be called without instantiating the class.  That means you can do:

Program.Main();

without having to instantiate Program class first like:

var program = new Program();
program.Main();

Here is an example with non-static methods called from Main();

using System; public class Program...

 

Page 8 of 10