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

Hiding Base Class Members

Sometimes it’s useful to hide a base class member by introducing a member with the same name of a subclass. After all, when defining a subclass, you don’t control the names chosen by the author of the base class. If it turns out the best name for the new member to be introduced on the subclass clashes with a member’s name on the base, hiding can be used. Later, in the section called “Interfaces,” you see how a similar situation can arise when an interface is being implemented.

The following example illustrates what we’re talking about for both instance and static members. Although we’re only showing methods here, the same applies for various other member types:

class Bar{    public void ...

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