proteced vs internal vs protected internal

Most C# devel­op­ers will know what “pub­lic”, “pri­vate”, “pro­tect­ed” and “inter­nalaccess mod­i­fiers mean and would have had to use them in their code, but rarely do we come across the “pro­tect­ed inter­nal” access mod­i­fi­er.

Now, pro­tect­ed means the type or mem­ber can be accessed by derived class­es, NOT restrict­ed to the same assem­bly, where­as inter­nal means the type or mem­ber can be accessed by code ONLY in the same assem­bly. It’s easy (and com­mon) to think of the access mod­i­fiers in a lin­ear sense where pri­vate is the most restric­tive, and pro­tect­ed, inter­nal and ulti­mate­ly pub­lic becomes less and less restric­tive:


This is cer­tain­ly the case with­in the SAME assem­bly, but when you have mul­ti­ple assem­blies this no longer holds true as types might be derived out­side of the assem­bly it’s declared in:


And that is what pro­tect­ed inter­nal gives you – acces­si­bil­i­ty from any derived class­es any­where, as well as any class from with­in the same assem­bly.