-
class Program
- {
- static void Main(string[] args)
- {
- InBox son = new InBox();
- son.m1();
- son.m2();
-
Console.WriteLine("转换成父类");
- Box box = (Box)son;
- box.m1();
- }
- }
-
-
-
class Box
- {
- public void m1()
- {
- Console.WriteLine("我是父类的方法");
- Console.ReadLine();
- }
- }
-
-
class InBox : Box
- {
- public void m2()
- {
- Console.WriteLine("我是子类的方法");
- Console.ReadLine();
- }
-
}
相关文章:
-
2021-11-04
-
2021-06-03
-
2021-11-29
-
2021-09-22
-
2021-06-03
-
2021-08-24
-
2022-12-23
-
2021-07-03
猜你喜欢
-
2022-12-23
-
2021-05-03
-
2021-10-18
-
2021-12-10
-
2022-12-23
-
2021-11-05
-
2022-02-10
相关资源
-
下载
2023-01-16
-
下载
2021-06-05
-
下载
2023-03-15
-
下载
2021-06-23