Think about protected internal
as applying two access modifier (protected
, and internal
) on the same field, property or method.
In the real world, imagine we are issuing privilege for people to visit museum:
- Everyone inside the city are allowed to visit museum (internal).
- Everyone outside of the city that their parents live here are allowed to visit museum (protected).
And we can put them together in these way:
Everyone inside the city (internal) and everyone outside of city that their parents live here (protected) are allowed to visit the museum (protected internal).
Programming world:
internal: The field is available everywhere in the assembly (project). It is like saying it is public
in its project scope (but can not being accessed outside of project scope even by those classes outside of assembly which inherit from that class). Every instance of that type can see it in that assembly (project scope).
protected: simply means that all derived classes can see it (inside or outside of assembly). For example derived classes can see the field or method inside its methods and constructors using: base.NameOfProtectedInternal
.
So, putting these two access modifier together (protected internal
), you have something that can being public inside the project, and can be seen by those which have inherited from that class inside their scope.
They can be written in the
internal protected
, and does not change the meaning, but it is convenient to write itprotected internal
.