internal in C#

Access modifiers in C#

Posted on Updated on

List of Access Modifiers in C#:

Public: When Members of a class are declared as public, then they can be accessed

1. Within the class in which they are declared.
2. Within the derived classes of that class available within the same assembly.
3. Outside the class within the same assembly.
4. Within the derived classes of that class available outside the assembly.
5. Outside the class outside the assembly.

Internal: When Members of a class are declared as internal, then they can be accessed

1. Within the class in which they are declared.
2. Within the derived classes of that class available within the same assembly.
3. Outside the class within the same assembly.

Protected: When Members of a class are declared as protected, then they can be accessed

1. Within the class in which they are declared.
2. Within the derived classes of that class available within the same assembly.
3. Within the derived classes of that class available outside the assembly.

Protected internal: When Members of a class are declared as protected internal, then they can be accessed

1. Within the class in which they are declared.
2. Within the derived classes of that class available within the same assembly.
3. Outside the class within the same assembly.
4. Within the derived classes of that class available outside the assembly.

Private: Private members of a class are completely restricted and are accessible only within the class in which they are declared.

References:-
http://msdn.microsoft.com/en-us/library/wxh6fsc7.aspx
http://msdn.microsoft.com/en-us/library/ms173121.aspx