There was a discussion in this newsgroup over a year ago involving a
rather determined fellow who _swore_ that he had to do this. He decided
to write a tool that would alter the IL written by the compiler. I
don't know how that turned out (and I don't want to know--it was a
horrible idea).
The consensus at the time was that how you handle this situation
depends upon what it is you're trying to do, so with class names A, B,
and C, it's hard to say.
Typically, what's going on is that A's "foo" method (or property)
serves more than one purpose. The derived class B then overrides "foo"
in order to modify its behaviour, but in so doing makes it useful in
only one of the two possible contexts in which it can be used. C then
wants to call B's foo in one context, but in another context wants the
"other" way of using A's "foo", which B doesn't provide.
The solution is, as several here have pointed out, to create a new
method / property in B that exposes the functionality of "foo" for use
in that other context.
Now, the reason for all of the fancy language is that this all has to
do with semantics and design. What is "foo", exactly, and what is it
for? If it has two purposes, how would you name those? Let me give you
a concrete example. It may not be the best example going, but it serves
to illustrate the concept:
public class StockItem
{
public virtual decimal Price { get { ... }}
}
public class ImportedStockItem : StockItem
{
public override decimal Price { get { ... include import duties,
etc. ... }}
}
public class ImportedStockItemForInternalUse : ImportedStockItem
{
...
}
Yeah, I know: it's a stupid class hierarchy, but it's just for
illustration. What if, in class ImportedStockItemForInternalUse, you
needed to know the item's price before import duties, taxes, and other
stuff that was added in by the base class ImportedStockItem? How do you
get that?
You get that by realizing that StockItem.Price can be used for two
things in ImportedStockItemForInternalUse, and changing that class
accordingly:
public class ImportedStockItem : StockItem
{
public override decimal Price { get { ... include import duties,
etc. ... }}
public decimal PriceBeforeDutyAndTaxes { get { return base.Price;
}}
}
The point is that you expose base.Price as a second property (or
method), but with a name that explains why you're doing that, not with
some lame name like "BaseClassPrice". It's all about asking, "What does
this information mean, and why do I need it?"