Do the available access modifiers matter for the method Main? If not, why does Main allow us to specify the modifier? Why does the compiler not prevent us from specifying something that are trivial?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Main being public/private does not affect the CLR calling it at all.
The CLR will look for a static method named main (by default, but not necessarily) which is associated with its entry point, without looking at access modifiers.
It only affects the visibility of main to the other functions.
Good practice is for Main to not be public since it is not to be called by other methods in your assemblies, only by the CLR.