vb.netaccess-levels

What is the use-case for Private Protected members in VB.NET 15.5?


VB.NET 15.5 introduced an additional access level for class members: Private Protected, as documented here and here.

An example is given as

Private Protected internalValue As Integer

My understanding is that this should be equivalent to just Protected, meaning it is accessible in the same class and its children, but not outside.

So when is this useful and what is the difference to Protected members?


Solution

  • The Private Protected modifier makes a class member accessible by derived types, but only within its containing assembly.

    Without the Private, a Protected member is accessible to derived classes in different assemblies too.