C#类和成员(字段,方法等)的默认可见性?

我正在尝试找到C#各个方面的默认可见性的参考.类类型,字段,方法,枚举等

有人可以提供这些列表以及它们的默认可见性(即没有前缀修饰符)吗?

最佳答案
您正在寻找的所有信息都可以在herehere找到(感谢Reed Copsey):

从第一个链接:

Classes and structs that are declared directly within a namespace (in other words, that are not nested within other classes or structs) can be either public or internal. Internal is the default if no access modifier is specified.

The access level for class members and struct members, including nested classes and structs, is private by default.

interfaces default to internal access.

Delegates behave like classes and structs. By default, they have internal access when declared directly within a namespace, and private access when nested.

从第二个链接:

Top-level types, which are not nested in other types, can only have internal or public accessibility. The default accessibility for these types is internal.

对于嵌套类型:

Members of    Default member accessibility
----------    ----------------------------
enum          public
class         private
interface     public
struct        private

转载注明原文:C#类和成员(字段,方法等)的默认可见性? - 代码日志