+ 2

Why we use static keyword in main method?

8th Nov 2016, 10:10 AM
Faiyaz
Faiyaz - avatar
2 Respuestas
+ 1
A main method is static because it is available to run when your program starts and as it is the entry point of the program it runs without creating an instance of the class. In other words, static functions exist before a class is instantiated so static is applied to the main entry point (Main method).
8th Nov 2016, 12:09 PM
மனோஜ்குமார் பழனிச்சாமி
மனோஜ்குமார் பழனிச்சாமி - avatar
0
The Main method is the entry point of your C# program. A static method is a method which can be called without creating an instance of the class. So in other words, the compiler can execute the Main method without the need to create an instance of the class containing the Main method.
8th Nov 2016, 11:13 AM
Andrei Dragomir