06needhamt
06needhamt

Reputation: 1605

What is the Difference Between 'Protected Friend' and 'Private Protected'?

I am currently relearning VB.NET coming from a C# and VB6 background and I have come across the 'Protected Friend' and 'Private Protected' access modifier combinations described in the documentation here.

However, I am having trouble understanding the difference between the two combinations and how you can have something that is declared both private and protected.

Is there a an open-source project that demonstrates the difference? I think it would be easier to understand the difference(s) in a real-world situation.

Upvotes: 3

Views: 2103

Answers (1)

LeoMurillo
LeoMurillo

Reputation: 6774

It is an OR vs AND difference:

Protected Friend specifies that the element can be accessed either from within the class or from derived classes or from within the same assembly.

Private Protected specifies that the element can be accessed only from within the same class, as well as from derived classes, (and = only if) found in the same assembly as the containing class.

See Access Levels in Visual Basic.

Upvotes: 4

Related Questions