using System;
class BaseClass
{
virtual public void Print(){
Console.WriteLine("This is the base class.");
}
}
class DerivedClass : BaseClass
{
override public void Print() {
Console.WriteLine("This is the derived class.");
}
}
class SecondDerived : DerivedClass
{
override public void Print()
{
Console.WriteLine("This is the second derived class.");
}
}
class MainClass
{
static void Main()
{
SecondDerived derived = new SecondDerived();
BaseClass mybc = (BaseClass)derived;
derived.Print();
mybc.Print();
}
}
This is the second derived class.
This is the second derived class.