O'Reilly logo

C# 5.0 Unleashed by Bart De Smet

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Protected Accessibility

So far, we’ve mostly dealt with publicly accessible members during our explanation of inheritance. However, a more granular accessibility level, called protected, exists for use in combination with inheritance and OOP.

Whereas public members are visible to the world, both inside and outside the assembly, private members are visible only within the declaring type (including nested types). Because type hierarchies establish “families of types,” a corresponding accessibility level seems attractive. This is what protected does: It allows access to the member to code in the declaring type as well as code in derived types. You’ve seen such an example with our introductory Counter exploration:

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required