What are the entry points of C# program
Description
All C# applications begin execution by calling Main( ). Main is the entry point method for a C# application.
Syntax
C# console application regards the following signatures for its entry main function:
public static void Main();
public static void Main(string[] args);
public static int Main();
public static int Main(string[] args);
Example
The main function returning an int status.
using System;// w w w . j av a 2 s . co m
class MainClass
{
public static int Main()
{
Console.WriteLine("Hello, Universe!");
return(0);
}
}
The code above generates the following result.
Example 2
using System;/* w w w.jav a 2 s.co m*/
class Program
{
static void Main(string[] args)
{
Console.WriteLine(args.Length);
foreach (string arg in args){
Console.WriteLine(arg);
}
}
}
The code above generates the following result.