+ 1
Main Method in C#
Why is the main method in C# static?
4 Réponses
+ 9
A static method can be called without instantiating an object. Therefore main() needs to be static in order to allow it to be the entry to your program.
To make it more clear, go through the official C# documentation:
https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/main-and-command-args/
+ 9
@Patryk: Have a look at the link above, it makes it clearer. Though, you might need to check this out, too:
https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/static
+ 2
What do u mean "Therefore main() needs to be static in order to allow it to be the entry to your program"?
+ 2
Thank you :)