---
title: "Missing C# feature ? - Totally hiding derived members"
url: "https://osherove.com/blog/2003/2/24/missing-c-feature-totally-hiding-derived-members.md"
canonical: "https://osherove.com/blog/2003/2/24/missing-c-feature-totally-hiding-derived-members.html"
published: "2003-02-24T17:39:00"
updated: "2003-02-24T17:39:00"
tags: []
author: "Roy Osherove"
description: "So here's my problem. I have class Foo: public class Foo{ public void DoStuff() { ... } } and i have class Bar derived from it. I want class Bar to Hide the \"DoStuff\" and expose it's own implementation of \"DoStuff()\".…"
usage: "Licensed under CC BY 4.0 — reuse, quote and adapt with attribution (Roy Osherove, link to the original page)."
license: "https://creativecommons.org/licenses/by/4.0/"
---

# Missing C\# feature ? - Totally hiding derived members

By Roy Osherove February 24, 2003

**Historical article** · Originally published February 24, 2003; technical details may be outdated.

So here's my problem. I have class Foo:

public class Foo{

public void DoStuff()

{

...

}

}

and i have class Bar derived from it. I want class Bar to Hide the "DoStuff" and expose it's own implementation of "DoStuff()". Simple, right?

public class Bar:Foo

{

//Hide the default memebr

new private void DoStuff(){

}

public void DoStuff(int argument){}

}

Ok. Done. But watch this: writing the following line in VS.NET:

Bar b = new Bar();

b.    ///->>>>You get both the Bar.DoStuff AND the Foo.DoStuff in the Tooltips.

meaning : you cannot hide inharited members totally. you must implement them to hide the default functionality. I looked it up on MSDN and found [this article](http://msdn.microsoft.com/library/default.asp?url=/library/en-us/csspec/html/vclrfcsharpspec_3_7_1_2.asp) which states so clearly:

_"A declaration of a new member hides an inherited member only within the scope of the new member._

```
class Base
{
   public static void F() {}
}
class Derived: Base
{
   new private static void F() {}   // Hides Base.F in Derived only
}
class MoreDerived: Derived
{
   static void G() { F(); }         // Invokes Base.F
}
```

_In the example above, the declaration of `F` in `Derived` hides the `F` that was inherited from `Base`, but since the new `F` in `Derived` has private access, its scope does not extend to `MoreDerived`. Thus, the call `F()` in `MoreDerived.G` is valid and will invoke `Base.F`."_

How is that not possible? you'd think it's a pretty legitimate programming way, wouldn;t you? I can;t think of any situation where having this as a possibility is a bad thing...


---

## About the author

**Roy Osherove**: Senior Solutions Architect at AWS working on AI for production and AI-driven development; author of The Art of Unit Testing and Elastic Leadership, with about 20 years of consulting and training on unit testing, TDD, team leadership and continuous delivery.

### Sites

- [RobotPaper](https://robotpaper.ai/): This blog: AI patterns and anti-patterns, AI and coding agents, and engineering leadership.
- [osherove.com](https://osherove.com): Roy's personal site. Author of The Art of Unit Testing and Elastic Leadership; consulting and training on unit testing, TDD, team leadership and continuous delivery, plus about 20 years of blog posts.
- [The Art of Unit Testing](https://www.artofunittesting.com): The Art of Unit Testing, 3rd Edition (Manning): readable, maintainable, trustworthy unit tests, plus TDD workshops in C#, JavaScript, Java and Kotlin.
- [5whys.com](https://www.5whys.com): Roy's writing on software team leadership: self-organizing teams, surviving chaos, learning mode and the Elastic Leadership model.
- [Pipeline Driven](https://pipelinedriven.org): Continuous delivery and DevOps practices: build patterns, pipeline-friendly testing, DevOps metrics and enterprise DevOps.
- [Elastic Leadership](https://www.elasticleadership.com): Elastic Leadership, Roy's framework for software team leaders (survival, learning and self-organizing modes).

### Social

- X: https://x.com/royosherove
- LinkedIn: https://www.linkedin.com/in/osherove/

### Contact

- Contact form: https://forms.gle/jQSx5KoXvrVA1JCK7

### License

Licensed under CC BY 4.0 — reuse, quote and adapt with attribution (Roy Osherove, link to the original page). License: https://creativecommons.org/licenses/by/4.0/
