using System;
class Base
{
public virtual void WhoAmI()
{
Console.WriteLine("Base");
}
}
class Derived: Base
{
public override void WhoAmI()
{
Console.WriteLine("Derived");
}
}
public class TotheBaseClassofanObject {
public static void Main()
{
Derived d = new Derived();
Base b = d;
b.WhoAmI();
Derived d2 = (Derived) b;
object o = d;
Derived d3 = (Derived) o;
}
}
|