old-code/monodoc/ecma334/10.5.1.xml

6 строки
3.1 KiB
XML

<?xml version="1.0"?>
<clause number="10.5.1" title="Declared accessibility">
<paragraph>The declared accessibility of a member can be one of the following: <list><list_item> Public, which is selected by including a public modifier in the member declaration. The intuitive meaning of public is &quot;access not limited&quot;. </list_item><list_item> Protected, which is selected by including a protected modifier in the member declaration. The intuitive meaning of protected is &quot;access limited to the containing class or types derived from the containing class&quot;. </list_item><list_item> Internal, which is selected by including an internal modifier in the member declaration. The intuitive meaning of internal is &quot;access limited to this program&quot;. </list_item><list_item> Protected internal, which is selected by including both a protected and an internal modifier in the member declaration. The intuitive meaning of protected internal is &quot;access limited to this program or types derived from the containing class&quot;. </list_item><list_item> Private, which is selected by including a private modifier in the member declaration. The intuitive meaning of private is &quot;access limited to the containing type&quot;. </list_item></list></paragraph>
<paragraph>Depending on the context in which a member declaration takes place, only certain types of declared accessibility are permitted. Furthermore, when a member declaration does not include any access modifiers, the context in which the declaration takes place determines the default declared accessibility. <list><list_item> Namespaces implicitly have public declared accessibility. No access modifiers are allowed on namespace declarations. </list_item><list_item> Types declared in compilation units or namespaces can have public or internal declared accessibility and default to internal declared accessibility. </list_item><list_item> Class members can have any of the five kinds of declared accessibility and default to private declared accessibility. <note>[Note: A type declared as a member of a class can have any of the five kinds of declared accessibility, whereas a type declared as a member of a namespace can have only public or internal declared accessibility. end note]) </note></list_item><list_item> Struct members can have public, internal, or private declared accessibility and default to private declared accessibility because structs are implicitly sealed. Struct members introduced in a struct (that is, not inherited by that struct) cannot have protected or protected internal declared accessibility. <note>[Note: A type declared as a member of a struct can have public, internal, or private declared accessibility, whereas a type declared as a member of a namespace can have only public or internal declared accessibility. end note]) </note></list_item><list_item> Interface members implicitly have public declared accessibility. No access modifiers are allowed on interface member declarations. </list_item><list_item> Enumeration members implicitly have public declared accessibility. No access modifiers are allowed on enumeration member declarations. </list_item></list></paragraph>
</clause>