Consider the following -
void Main()
{
var c = new C();
c.Print();
}
public abstract class A
{
public virtual void Print()
{
Console.WriteLine("I'm in A!");
}
}
public abstract class B : A
{
public abstract override void Print();
}
public class C : B
{
public override void Print()
{
Console.WriteLine("I'm in C!");
base.Print();
}
}
This, of course, won't compile, as it thinks I am trying to invoke B's print method, which is abstract. What I want to do is call C's print method, and then have it call the base's print method, which would "chain" back to A's print method. I would like the output to be -
I'm in C!
I'm in A!
Is doing this even possible? What am I doing wrong?
EDIT: I'd like to add that the main point about the code above is that I'm trying to force anyone that extends B to implement their own Print method.