Table of Contents 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 Notes DownloadECMA-334 C# Language Specification


10 Basic concepts
10.5 Member access
10.5.1 Declared accessibility
Paragraph 11 The declared accessibility of a member can be one of the following: - 2 Public, which is selected by including a public modifier in the member declaration. 3 The intuitive meaning of public is "access not limited".
- 4 Protected, which is selected by including a protected modifier in the member declaration. 5 The intuitive meaning of protected is "access limited to the containing class or types derived from the containing class".
- 6 Internal, which is selected by including an internal modifier in the member declaration. 7 The intuitive meaning of internal is "access limited to this program".
- 8 Protected internal, which is selected by including both a protected and an internal modifier in the member declaration. 9 The intuitive meaning of protected internal is "access limited to this program or types derived from the containing class".
- 10 Private, which is selected by including a private modifier in the member declaration. 11 The intuitive meaning of private is "access limited to the containing type".
Paragraph 21 Depending on the context in which a member declaration takes place, only certain types of declared accessibility are permitted. 2 Furthermore, when a member declaration does not include any access modifiers, the context in which the declaration takes place determines the default declared accessibility. - 3 Namespaces implicitly have public declared accessibility. 4 No access modifiers are allowed on namespace declarations.
- 5 Types declared in compilation units or namespaces can have public or internal declared accessibility and default to internal declared accessibility.
- 6 Class members can have any of the five kinds of declared accessibility and default to private declared accessibility. [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])
- 7 Struct members can have public, internal, or private declared accessibility and default to private declared accessibility because structs are implicitly sealed. 8 Struct members introduced in a struct (that is, not inherited by that struct) cannot have protected or protected internal declared accessibility. [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])
- 9 Interface members implicitly have public declared accessibility. 10 No access modifiers are allowed on interface member declarations.
- 11 Enumeration members implicitly have public declared accessibility. 12 No access modifiers are allowed on enumeration member declarations.
|
Jagger Software Ltd |
Company # 4070126 |
VAT # 762 5213 42 |

