加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

C# 默认访问修饰符

发布时间:2020-12-15 04:45:31 所属栏目:百科 来源:网络整理
导读:[MSDN] Classes and structs that are not nested within other classes or structs can be either public or internal. A type declared as public is accessible by any other type. A type declared as internal is only accessible by types within the

[MSDN]

Classes and structs that are not nested within other classes or structs can be either public or internal. A type declared as public is accessible by any other type. A type declared as internal is only accessible by types within the same assembly. Classes and structs are declared as internal by default unless the keyword?public?is added to the class definition,as in the previous example. Class or struct definitions can add the?internal?keyword to make their access level explicit. Access modifiers do not affect the class or struct itself — it always has access to itself and all of its own members.

[MSDN]

Interfaces,like classes,can be declared as public or internal types. Unlike classes,interfaces default to internal access. Interface members are always public,and no access modifiers can be applied.

Namespaces and enumeration members are always public,and no access modifiers can be applied.

Delegates have internal access by default.

Any types declared within a namespace or at the top level of a compilation unit (for example,not within a namespace,class,or struct) are internal by default,but can be made public.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读