Can anyone explain to me why this works the way it does. The output comes out to "Print This"
. But how does the base class call bar()
, when there is no implementation.
abstract class Base
{
protected virtual void foo()
{
bar();
}
protected abstract void bar();
}
class Sub : Program
{
protected override void foo()
{
base.foo();
}
protected override void bar()
{
Console.WriteLine("Print This");
}
static void Main(string[] args)
{
Sub obj = new Sub();
obj.foo();
}
}
See Question&Answers more detail:os