参考自Default visibility for C# classes and members (fields, methods, etc)?

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.

直接声明在命名空间下的类和结构体,默认是internal的。

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

类和结构体的成员,包括内嵌的类和结构体,默认是private的

interfaces default to internal access.

接口默认是internal的

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

委托和类以及结构体类似。直接声明在命名空间下的访问权限默认是internal的。如果内嵌的话,就是private的。

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.

总结,最高等级的类型(没有内嵌在其他类型中),只能有internal和public的访问权限。这些类型默认的访问权限是internal

然而对于内嵌的类型来说
And for nested types:
Members of Default member accessibility
---------- ----------------------------
enum public       //enum的成员是public的访问权限
class private      //类的成员,默认是private的访问权限
interface public  //接口的成员,默认是public的访问权限
struct private    //结构体的成员,和class类似,默认的访问权限也是private的

C#中默认的修饰符的更多相关文章

  1. C#中的默认访问修饰符

    1.命名空间下的元素的默认访问修饰符 public : 同一程序集的其他任何代码或引用该程序集的其他程序集都可以访问该类型或成员.internal : 同一程序集中的任何代码都可以访问该类型或成员,但 ...

  2. C#中方法、类等的默认访问修饰符~

    C# 方法默认访问级别 : private C# 类默认访问级别 : internal 1.命名空间下的元素的默认访问修饰符 public : 同一程序集的其他任何代码或引用该程序集的其他程序集都可以 ...

  3. [.net 面向对象编程基础] (8) 基础中的基础——修饰符

    [.net 面向对象编程基础] (8) 基础中的基础——修饰符 在进入C#面向对象核心之前,我们需要先对修饰符有所了解,其实我们在前面说到变量和常量的时候,已经使用了修饰符,并且说明了变量和常量的修改 ...

  4. C#的默认访问修饰符

    Classes and structs that are not nested within other classes or structs can be either public or inte ...

  5. java中的类修饰符、成员变量修饰符、方法修饰符。

    类修饰符: public(访问控制符),将一个类声明为公共类,他可以被任何对象访问,一个程序的主类必须是公共类. abstract,将一个类声明为抽象类,没有实现的方法,需要子类提供方法实现. fin ...

  6. java中的类修饰符、成员变量修饰符、方法修饰符

    类修饰符:  public(访问控制符),将一个类声明为公共类,他可以被任何对象访问,一个程序的主类必须是公共类. abstract,将一个类声明为抽象类,没有实现的方法,需要子类提供方法实现. fi ...

  7. C# 默认访问修饰符

    c# 中类,成员,枚举,结构等默认访问修饰符是? 根据MSDN文档有: [MSDN] Classes and structs that are not nested within other clas ...

  8. Java学习笔记十九:Java中的访问控制修饰符

    Java中的访问控制修饰符 一:Java修饰符的种类: 访问修饰符 非访问修饰符 修饰符用来定义类.方法或者变量,通常放在语句的最前端.我们通过下面的例子来说明: public class Hello ...

  9. 20151024_004_C#基础知识(C#中的访问修饰符,继承,new关键字,里氏转换,is 和 as,多态,序列化与反序列化)

    1:C#中的访问修饰符 public: 公共成员,完全公开,没有访问限制. private: 私有的,只能在当前类的内部访问. protected: 受保护的,只能在当前类的内部以及该类的子类中访问. ...

随机推荐

  1. ZOJ 2314 带上下界的可行流

    对于无源汇问题,方法有两种. 1 从边的角度来处理. 新建超级源汇, 对于每一条有下界的边,x->y, 建立有向边 超级源->y ,容量为x->y下界,建立有向边 x-> 超级 ...

  2. cocos2dx中的设计分辨率与屏幕适配策略

    1.首先明确几个概念: 设计分辨率:designResolution,即资源图片的设计尺寸,即美工给你的资源图片的大小,比如(641*964) 屏幕分辨率:又叫帧的大小,glview->setF ...

  3. 怎么直接在MySQL客户端上执行SQl文件?

    \. 直接把sql文件拖进去就行了,(斜杠+.+空格+sql文件)

  4. (转)使用 /proc 文件系统来访问 Linux 内核的内容

    转载网址:http://www.ibm.com/developerworks/cn/linux/l-proc.html 这个虚拟文件系统在内核空间和用户空间之间打开了一个通信窗口/proc 文件系统是 ...

  5. eclipse不能创建java虚拟机-解决方法

    找到eclipse目录下的eclipse.ini,可以看到如下内容: -startup plugins/org.eclipse.equinox.launcher_1.1.0.v20100507.jar ...

  6. Codeforces Round #130 (Div. 2) A. Dubstep

    题目链接: http://codeforces.com/problemset/problem/208/A A. Dubstep time limit per test:2 secondsmemory ...

  7. PAT-乙级-1046. 划拳(15)

    1046. 划拳(15) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 8000 B 判题程序 Standard 作者 CHEN, Yue 划拳是古老中国酒文化的一个有趣的组成部分 ...

  8. BT5之Metasploit[MSF]连接postgresql数据库

    1,先查看postgresql的端口,默认是自动开启的,端口7337 .   root@bt:~# netstat -tnpl |grep postgres tcp        0      0 1 ...

  9. Open Phone, SMS, Email, Skype and Browser apps of Android in Unity3d

    最近项目需要使用Android的一些基本功能,写插件各种悲剧,google了一下,如获至宝.Nice ! string url = String.Format("tel:{0}", ...

  10. [转载]Spring Web MVC Framework

    Required Configuration You need to map requests that you want the DispatcherServlet to handle, by us ...