欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

C#虚函数用法实例分析

程序员文章站 2023-11-17 14:40:16
本文实例讲述了c#虚函数用法。分享给大家供大家参考。具体如下: using system; namespace test2 { class plane {...

本文实例讲述了c#虚函数用法。分享给大家供大家参考。具体如下:

using system;
namespace test2 {
  class plane {
   public double topspeed() {
     return 300.0d;
   }
  }
  class jet : plane {
   public double topspeed() {
     return 900.0d;
   }
  }
  class airport {
   static void main(string[] args) {
     plane plane = new jet();
     console.writeline("planes top speed: {0}",plane.topspeed());
     console.readline();
   }
  }
}

希望本文所述对大家的c#程序设计有所帮助。