返回顶部

收藏

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();
      }
   }

标签:属性,property,C#

收藏

0人收藏

支持

0

反对

0