gpt4 book ai didi

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

转载 作者:IT王子 更新时间:2023-10-29 03:31:31 29 4
gpt4 key购买 nike

我正在尝试查找有关 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          publicclass         privateinterface     publicstruct        private

关于c# - C# 类和成员(字段、方法等)的默认可见性?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3763612/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com