本文實例講述了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#程序設計有所幫助。
新聞熱點
疑難解答