InterviewSolution
| 1. |
Accessibility Modifiers in C# |
|
Answer» The ACCESSIBILITY of a member or a TYPE is specified using ACCESS modifiers. The four main access modifiers are given as follows: 1. public The members that are public can be accessed without restrictions. So this is the most permissive accessibility modifier. 2. protected The members that are protected can be accessed in the class in which they were declared or from any derived classes that were derived from the class that declared the member in question. 3. internal The members that are internal can only be accessed from the files that are in the same assembly. Any class or a class member can be declared as internal. 4. private The members that are private can only be accessed in the class or structure in which they were declared and not outside. So, this is the LEAST permissive accessibility modifier. There are six accessibility levels that can be specified from the above access modifiers. These are given as follows:
There is unrestricted access.
The access is restricted to the containing class or the various classes and types that are derived from the containing class.
The access is restricted to the files that are in the same assembly.
The access is restricted to the various classes and types that are derived from the containing class and the files that are in the same assembly.
The access is restricted to the containing class or type.
The access is restricted to the containing class and types that are derived from the containing class in the same assembly. |
|