Access Modifiers
How is encapsulation done in C#?
Access specifiers/modifiers help implement Encapsulation in C#.
Declared accessibility | Meaning |
---|---|
| Access is not restricted. |
| Access is limited to the current assembly. |
| Access is limited to the containing class or types derived from the containing class. |
| Access is limited to the containing type ( |
| Access is limited to the current assembly or types derived from the containing class. |
| Access is limited to the containing class or types derived from the containing class within the current assembly. |
An assembly is a .dll
or .exe
created by compiling one or more .cs
files in a single compilation.
Top-level types, which are not nested in other types, can only have internal
or public
accessibility. The default accessibility for these types is internal
.
Members of | Default member accessibility | Allowed declared accessibility of the member |
---|---|---|
|
| None |
|
|
|
|
|
|
|
|
|
* An interface
member with private
accessibility must have a default implementation.
Last updated