Accessibility Levels (C# Reference)
Updated: July 20, 2015
|Access is not restricted.|
|Access is limited to the containing class or types derived from the containing class.|
|Access is limited to the current assembly.|
|Access is limited to the current assembly or types derived from the containing class.|
|Access is limited to the containing type.|
Only one access modifier is allowed for a member or type, except when you use the
Access modifiers are not allowed on namespaces. Namespaces have no access restrictions.
Depending on the context in which a member declaration occurs, only certain declared accessibilities are permitted. If no access modifier is specified in a member declaration, a default accessibility is used.
Top-level types, which are not nested in other types, can only have
public accessibility. The default accessibility for these types is
Nested types, which are members of other types, can have declared accessibilities as indicated in the following table.
|Members of||Default member accessibility||Allowed declared accessibility of the member|
The accessibility of a nested type depends on its accessibility domain, which is determined by both the declared accessibility of the member and the accessibility domain of the immediately containing type. However, the accessibility domain of a nested type cannot exceed that of the containing type.
For more information, see the C# Language Specification. The language specification is the definitive source for C# syntax and usage.