I wonder if something like this is possible in C#:
public class A
{
public string Foo() { return "Foo"; }
}
public class B : A
{
public string Bar() { return Foo(); }
}
public class C : B
{
public new string B.Foo() { return "Bar"; } // Hide A.Foo in B
}
Main()
{
C c = new C();
Console.WriteLine(c.Bar()); // Want to get "Bar"
}
by public new string B.Foo() { return "Bar"; }
I mean do something in C (without changing A or B) that has the equivalent result as if public new string Foo() { return "Bar"; }
was implemented in B. So, hide a method FOR a base class OF a base further up the inheritance hierarchy.