博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
C#的默认访问修饰符
阅读量:6480 次
发布时间:2019-06-23

本文共 1510 字,大约阅读时间需要 5 分钟。

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.

类(class)或结构(struct)如果不是在其它类或结构中的话,它的访问类型要不就是internal, 要不就是public;换句话说,如果它在其它类或结构中的话,则可以为private 或protected等。下面提到的类和结构,如无特殊说明,均指非"类中类"。

类或结构的默认访问类型是internal.

类中所有的成员,默认均为private。

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.

接口默认访问符是internal

接口的成员默认访问修饰符是public,也不可能是其他访问修饰符

命名空间,枚举类型成员默认public,也不可能是其他访问修饰符

委托,默认internal

在命名空间内部或编译单元顶部的所有类型,默认是internal,可以人为改为public。

转载于:https://www.cnblogs.com/action98/p/3483895.html

你可能感兴趣的文章
观察者模式
查看>>
在properties.xml中定义变量,在application.xml中取值问题
查看>>
js 数组
查看>>
cell reuse & disposebag
查看>>
【故障处理】ORA-12545: Connect failed because target host or object does not exist
查看>>
云时代,程序员将面临的分化
查看>>
js判断移动端是否安装某款app的多种方法
查看>>
学习angularjs的内置API函数
查看>>
4、输出名称 Exported names
查看>>
Pre-echo(预回声),瞬态信号检测与TNS
查看>>
【转载】如何发送和接收 Windows Phone 的 Raw 通知
查看>>
poj2378
查看>>
Java文件清单列表
查看>>
js url传值中文乱码之解决之道
查看>>
Trusty TEE
查看>>
[LeetCode] Reverse String 翻转字符串
查看>>
学习iOS【3】数组、词典和集合
查看>>
Hessian 原理分析--转
查看>>
转: 基于netty+ protobuf +spring + hibernate + jgroups开发的游戏服务端
查看>>
easyui传入map的数据前台展示出tree格式数据
查看>>