Access modifiers are keywords used to control access to a member (method/member variables/properties) or a type. Following are the access modifiers available in c#
Private
-
Only Accessible in the class they are declared.
-
Cannot be applied to types (classes, structs etc.) directly under a namespace, but can be used for sub classes (class defined inside a class) or sub structs.
Protected
-
Accessible in the class they are declared
-
Accessible in all derived classes in any assembly
-
Cannot be applied to types (classes, structs etc.) directly under a namespace, but can be used for sub classes (class defined inside a class) or sub structs.
Internal
-
Accessible anywhere in the same assembly they are declared in
-
Can be applied to types (e.g internal class xyz { ... }) & members
Protected Internal
-
Accessible anywhere in the same assembly they are declared in
-
Outside the assembly accessible only to classes derived from the class they are declared in
-
Cannot be applied to types (classes, structs etc.) directly under a namespace, but can be used for sub classes (class defined inside a class) or sub structs.
Public
-
Accessible anywhere without restrictions
-
Can be applied to types & members