How does the runtime know which class contains the Main method in a C # application?

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

If we have hundreds of classes in our application, how will the runtime determine which class contains the “Primary” method to run the application?

+5
source share
2 answers

The compiler is looking

static void Main(string[])

or

static int Main(string[])

to determine the entry point. Main()can also be declared without an argument string[]. You only need to set the project settings if you have several classes with functions Main().

Here is a detailed MSDN answer for you.

+1
source

The entry point can be configured in the project settings.

+1
source

All Articles