zoukankan      html  css  js  c++  java
  • 子类与父类的小关系:盒子套盒子

    1. class Program   
    2. {   
    3.     static void Main(string[] args)   
    4.     {   
    5.         InBox son = new InBox();   
    6.         son.m1();   
    7.         son.m2();   
    8.         Console.WriteLine("转换成父类");   
    9.         Box box = (Box)son;   
    10.         box.m1();     //从这儿就能看出,只有父类的方法,而没有子类的方法了?所以像不像是父类就是子类里的一个盒子?   
    11.     }   
    12. }   
    13.   
    14.   
    15. class Box   
    16. {   
    17.     public void m1()   
    18.     {   
    19.         Console.WriteLine("我是父类的方法");   
    20.         Console.ReadLine();   
    21.     }   
    22. }   
    23.   
    24. class InBox : Box   
    25. {   
    26.     public void m2()   
    27.     {   
    28.         Console.WriteLine("我是子类的方法");   
    29.         Console.ReadLine();   
    30.     }   
    31. }  
  • 相关阅读:
    mybatis的缓存机制
    mybatis动态SQL
    mybatis关联集合List&分布查询传递多列值
    winrt获取文件MD5码
    在wpf中使用winrt的Toast弹框效果
    winrt控件
    WdatePicker组件不显示
    Thread.Sleep in WinRT
    google 语音api
    UTF8编码转换(C#)
  • 原文地址:https://www.cnblogs.com/leeolevis/p/1486079.html
Copyright © 2011-2022 走看看