using System;
class Maruti
{
public virtual void Display()
{
Console.WriteLine("Maruti Car.");
}
}
class Esteem : Maruti
{
public override void Display()
{
Console.WriteLine("Maruti Esteem.");
}
}
class Zen : Maruti
{
public override void Display()
{
Console.WriteLine("Maruti Zen.");
}
}
class Inclusion
{
static void Main()
{
Maruti m=new Maruti();
m.Display();
m=new Esteem(); //Upcasting
m.Display();
m=new Zen(); //Upcasting
m.Display();
Console.ReadKey();
}
}
Output:-
No comments:
Post a Comment