1

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?

Arman Hayots
  • 2,459
  • 6
  • 29
  • 53

2 Answers2

2

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#

JaredPar
  • 733,204
  • 149
  • 1,241
  • 1,454
  • It's worth mentioning that **C# 7.2** introduces [protected private](https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/private-protected) modifier which provides such functionality. – gis Nov 26 '20 at 12:39
2

Also C++/CLI has 'ptrotected private' access modifier, member with it is accessible ONLY in derived classes ONLY in current assembly. You can find it here http://msdn.microsoft.com/en-us/library/vstudio/ke3a209d.aspx (the page is very long, just find 'private protected')

Piane_Ramso
  • 51
  • 1
  • 8