Override abstract method : Abstract Class « Class « C# / CSharp Tutorial






using System;

class MainClass
{
  static void Main(string[] args)
  {
    B MyB = new C();

    MyB.Display();
  }
}

abstract class A
{
  public abstract void Display();
}
class B: A
{
  public override void Display()
  {
    Console.WriteLine("Class B's Display Method");
  }
}
class C: B
{
  public override void Display()
  {
    Console.WriteLine("Class C's Display Method");
  }
}
class D: C
{
  public override void Display()
  {
    Console.WriteLine("Class D's Display Method");
  }
}
Class C's Display Method








7.27.Abstract Class
7.27.1.Using Abstract Classes
7.27.2.Create an abstract class.
7.27.3.Override abstract method
7.27.4.Polymorphism and Virtual Functions
7.27.5.Define abstract class and abstract method
7.27.6.abstract class with three virtual methods