#308 – Protected Internal Class Members

Class members marked with the accessibility keyword protected internal are accessible from within the same class, from within code in classes that derive from the class, or from within code in classes within the same assembly.

In the picture below, the Dog.DoBark method is marked as protected internal.  The code in any of the blue blocks can call this method.

Advertisement

#303 – Accessibility of Class Members

Members of a class can have different kinds of accessibility.  An accessibility keyword indicates what source code can access the member.  The different types of accessibility are:

Accessibility Keyword Description
public All code can access the member
private Only other code in the class can access the member
protected Code in this class or any class that inherits from this class can access
internal Code in files in the same assembly (.dll or .exe) can access
protected internal Code in the same assembly or in classes that inherit from this class can access

Accessibility keywords can apply to the following kinds of members of a class: fields, properties, methods, constants, indexers, events, constructors and nested types.  They can apply to both instance and static members.