Hi All, Can someone please elaborate me the difference between 'protected' and 'protected internal' modifiers in C#? It looks they behave in same manner.
From MSDN (click for more information):
protected:
The type or member can only be accessed by code in the same class or struct, or in a derived class.
internal:
The type or member can be accessed by any code in the same assembly, but not from another assembly.
protected internal:
The type or member can be accessed by any code in the same assembly, or by any derived class in another assembly.
"protected" can be used by any subclasses from any assembly.
"protected internal" is everything "protected" is, plus also anything in the same assembly can access it.
Importantly, it doesn't mean "subclasses in the same assembly" - it is the union of the two, not the intersection.
In practice, about methods:
protected - accessible for inherited classes, otherwise private
internal - public only inside it's class assembly, otherwise private
protected internal - means protected or internal - methods becomes accessible for inherited classes and
for anybody from it's assembly