See following points,
- Main() method is the starting point of a program.
- Main() method is always "Static".
- Main() should NOT be "Public". Default access specifier of Main() is Private.
- Following are the acceptable signatures of Main() method,
- static void Main(string[] args){}
- static void Main(){}
- staticint Main(string[] args){}
- staticint Main(){}
- Main() method can have either of the two return types - void and int.
- Main() method can either have input string arguments or none.
- There can be only one entry point in a program. However, we can have multiple Main() in the same project. But you need to define the "Startup object" defining which is the single entry point.
Sample Code:
We have two classes,
When you compile this program, you can see both classes listed as Startup objects in Property pages of the Project.- namespace ConsoleApplication2
- {
- //Class 1
- public class Class1
- {
- static void Main(string[] args)
- {}
- }
- //Class 2
- public class Class2
- {
- static void Main(string[] arg)
- {}
- }
- }
You need to select one of the two.

Join the conversation! Your thoughts help the community grow.