文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>C#:访问修饰符 Access Modifier

C#:访问修饰符 Access Modifier

时间:2011-06-07  来源:现古行

共有5个访问修饰符:public, private, protected, internal, protected internal

类本身有2道防线,一是命名空间(namespace),另一个是程序集(Assembly)。

成员则有3道防线,一是类,另外两个同类一样。

而访问修饰符则是类或成员走向外界的一把钥匙。

类存在于命名空间之下,只能为 public 或 internal修饰,默认为internal

成员则可以有5个访问修饰符,但默认为private, 默认遵循最小权利原则

 

The accessibility of the member cannot be greater than the type.

User-defined operators must always be declared as public.

Interface members are always public because the purpose of an interface is to enable other types to access a class or struct. No access modifiers can be applied to interface members.

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

相关阅读 更多 +
排行榜 更多 +
城市英雄机甲救援手游

城市英雄机甲救援手游

动作格斗 下载
星战模拟器MOD内置菜单

星战模拟器MOD内置菜单

模拟经营 下载
解压盒下载包

解压盒下载包

休闲益智 下载