C# 使用属性范例代码
public class Plane { protected double mySpeed = 300.0D; public double TopSpeed { get {return mySpeed;} set { mySpeed = value; } } } class Jet : Plane { public Jet() { TopSpeed = 900.0D; } } class Airport { [STAThread] static void Main(string[] args) { Plane plane = new Plane(); Console.WriteLine("plane's top speed: {0}",plane.TopSpeed); Jet jet = new Jet(); Console.WriteLine("jet's top speed: {0}",jet.TopSpeed); Console.ReadLine(); } }