same method names with same arguments and same return types associated in a class and its subclass.
Examples:
class BC
{
public virtual void Display()
{
System.Console.WriteLine("BC::Display");
}
}
class DC : BC
{
public override void Display()
{
System.Console.WriteLine("DC::Display");
}
}
class TC : DC
{
public override void Display()
{
System.Console.WriteLine("TC::Display");
}
}
class Demo
{
public static void Main()
{
BC b;
b = new BC();
b.Display();
b = new DC();
b.Display();
b = new TC();
b.Display();
}
}
Output
BC::Display
DC::Display
TC::Display
Examples:
class BC
{
public virtual void Display()
{
System.Console.WriteLine("BC::Display");
}
}
class DC : BC
{
public override void Display()
{
System.Console.WriteLine("DC::Display");
}
}
class TC : DC
{
public override void Display()
{
System.Console.WriteLine("TC::Display");
}
}
class Demo
{
public static void Main()
{
BC b;
b = new BC();
b.Display();
b = new DC();
b.Display();
b = new TC();
b.Display();
}
}
Output
BC::Display
DC::Display
TC::Display
No comments:
Post a Comment