Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How the runtime knows which class contain the Main method in C# application?

I know that for Console/Windows application in C#, "Main" method is entry point to run the application.

If we have hundreds of classes in our application, how the runtime will detect which class contains the "Main" method to run the application?

like image 915
Syed Avatar asked Oct 09 '22 16:10

Syed


1 Answers

The compiler looks for

static void Main(string[])

or

static int Main(string[])

to determine the entry point. Main() may also be declared without the string[] argument. You only need to specifically set the project setting if you have multiple classes with Main() functions.

Here's MSDN's detailed answer for you.

like image 148
xxbbcc Avatar answered Oct 12 '22 11:10

xxbbcc