Reputation: 479
In Java , generally we declare main method as public because it should be availbale out of class for JVM to execute.
But in c# , we declare main method as private ( default access specifier is private for method in c#). How main method is available to CLR to get executed?
Please forgive me for asking very simple question :)
Upvotes: 2
Views: 84
Reputation:
Access (Public, Private) modifiers are just for developers to prevent using unwanted methods or members. VM just needs a method to start execute your program regardless of its access modifier.
Upvotes: 1
Reputation: 384
The CLR doesn't actually mind if your method is private or public. It doesn't invoke it through the use of normal C# code.In native Call stack,CLR gets to Main method using .entrypoint IL directive
Upvotes: 6