C#虚函数用法实例分析
作者:pythoner
这篇文章主要介绍了C#虚函数用法,实例分析了C#中虚函数的功能与基本使用技巧,需要的朋友可以参考下
本文实例讲述了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#程序设计有所帮助。
