C#:访问修饰符 Access Modifier
共有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.