protected internal exposed

.NET gives developers a lot of freedom. In every version new features are added to ease them in their daily work. One of the simplest things that have existed since the first versions of .NET framework are access modifiers. Using them one sets the access to a specific class/method. Public, private, protected… all are standard modifiers. If you have experience with an object-oriented language you must know them by heart. .NET provides another modifier – internal. It allows access to a method only in the parent assembly (the one the corresponding class resides in).

.NET offers one interesting combination of modifiers – protected internal. How are we supposed to interpret this combination? The first association people make (including me) is for a conjunction – a protected internal method can be accessed only by a derived class which resides in the same assembly as the that method was declared in.

However the picture is not like that. Actually it is a disjunction – a protected internal method can be accessed by a derived class (from any assembly) or classes within the assembly that method was declared in.

Did you know that?