Search code examples
c#internalaccess-levels

Protected & internal, not protected or internal


Internal - public in assembly and private in other places.
Protected - only derived classes can have access to parent class members.
Protected internal - protected OR internal - public in assembly and protected in other places.
So, how to make parent class members accessible ONLY in assembly AND from derived classes?

If we are talking about IL, any ways to inject famandassem flag?


Solution

  • Unfortunately such a restriction is not possible in C# today. There is no keyword combination which will provide protected and internal. This is supported at the CLR level, it is just not exposed in C#