class MobbliePhone
   {
       public void Test()
       {
           Console.WriteLine("我是手机");
           Console.ReadLine();
       }
   }
   class Iphone : MobbliePhone
   {
       public void Test2()
       {
           Console.WriteLine("我是苹果");
           Console.ReadLine();
       }
   }
   class Nokia : MobbliePhone
   {
       public void Test3()
       {
           Console.WriteLine("我是诺基亚");
           Console.ReadLine();
       }
   }
   class Program
   {
       static void Main(string[] args)
       {
           Nokia[] nokia = new Nokia[2];
           //nokia[0] =new Iphone();  这是行不通的,因为同为子类的两个类型不同
          //所以需要用上向上转换
           MobbliePhone[] mobbliephone = new MobbliePhone[2];
           mobbliephone[0] = new Nokia();
           mobbliephone[1] = new Iphone();
           //因为mobhliephone是MobbliePhone类型的一个引用,不论他指向哪个对象,都只能调用MobbilePhone里的方法
           mobbliephone[0].Test(); //这样可以
           //mobhliephone[0].Test3(); 这样就不行,尽管它指向了Nokia而且你知道他是个Nokia类型。
           //这是需要用上向下转换,用as关键字可以做到这点
           if (mobbliephone[0] is Nokia)//用is关键字判断指向的对象是否是Nokia
           {
               Nokia lumia520 = mobbliephone[0] as Nokia; //用as关键字来完成向下转换
               lumia520.Test3();
                
           }
 
       }
   }