C# - Access Modifiers and Access Levels

Access Modifiers

All classes and class members can specify what access level they provide to other classes by using access modifiers.

The default accessibility of a class is internal. Private is the default accessibility of class members.

The following access modifiers are available:

C# ModifierDefinition
publicThe type or member can be accessed by any other code in the same assembly or another assembly that references it.
privateThe type or member can only be accessed by code in the same class.
protectedThe type or member can only be accessed by code in the same class or in a derived class.
internalThe type or member can be accessed by any code in the same assembly, but not from another assembly.
protected internalThe type or member can be accessed by any code in the same assembly, or by any derived class in another assembly.

Modifiers refine the declaration of a class. The list of all modifiers defined in the table are as follows;

Modifier Description
sealed Class can't be inherited by a derived class.
static Class contains only static members.
unsafeThe class that has some unsafe construct likes pointers.
Abstract The instance of the class is not created if the Class is abstract.