C# abstract关键字

using System;public abstract class Vehicle {public abstract void display();}public class Bus : Vehicle {

编程学习网为您整理以下代码实例,主要实现:C# abstract关键字,希望可以帮到各位朋友。

using System;

public abstract class Vehicle {
   public abstract voID display();
}

public class Bus : Vehicle {
   public overrIDe voID display() {
      Console.Writeline("Bus");
   }
}

public class Car : Vehicle {
   public overrIDe voID display() {
      Console.Writeline("Car");
   }
}

public class Motorcycle : Vehicle {
   public overrIDe voID display() {
      Console.Writeline("Motorcycle");
   }
}

public class MyClass {
   public static voID Main() {
      Vehicle v;
      v = new Bus();
      v.display();
      v = new Car();
      v.display();
      v = new Motorcycle();
      v.display();
   }
}

本文标题为:C# abstract关键字