C# Default access modifier of Main() method

后端 未结 6 1549
深忆病人
深忆病人 2021-01-12 05:43

I create a sample class in vs2010.

Through Class View, I see the default access modifier for Main is internal.

I also see some people say that the default ac

6条回答
  •  借酒劲吻你
    2021-01-12 06:19

    You can't see the default access modifier for a member in the class browser, you can see the actual access modifier.

    The default access modifiers for classes at the namespace level is internal, whereas the default access modifier for class members (including nested classes) is private. There's no special case for the Main() function. If there's no access modifier before it (a la Jon Skeet's example), then it's private. If there is one, then that's what it is.

提交回复
热议问题