C# Default access modifier of Main() method

后端 未结 6 1550
深忆病人
深忆病人 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:20

    Although you tagged your question c#, let me say that the access modifiers for the default Program.Main generated by VS2010 actually depends on the project template, on these differ for each language. I quickly tried the following:

    • In a VB.NET console project, the Program module (static class) is Friend (i.e. internal in C#) and the Main static method is Public.

    • In a C# console project, Program is internal, and Main is private.

    That is, a C# project will simply use the default access modifiers (internal for classes, private for methods).

提交回复
热议问题