How does this actually work? I thought Main was supposed to be "called". But how is that possible if it's marked private?
public class Program
{
private static void Main()
{
}
}
From Jon Skeet on bytes.com:
Basically, the execution of the main method is started by special code within the CLR (or possibly code driving the CLR to start with) which doesn't need to obey the same rules.
Source
Also, there's another question that covers this topic here already.
Following to MSDN the Main method should not be public:
Main is declared inside a class or struct. Main must be static and it should not be public. (In the earlier example, it receives the default access of private.) The enclosing class or struct is not required to be static.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With