C# 继承方法重写调用测试

 1     class BaseClass
 2     {
 3         public virtual void run()
 4         {
 5             Console.WriteLine("base run func....");
 6         }
 7     }
 8     class SubClass : BaseClass
 9     {
10         public override void run()
11         {
12             Console.WriteLine("sub run func....");
13             base.run();
14         }
15     }
16     class Program
17     {
18         static void Main(string[] args)
19         {
20             BaseClass bass = new SubClass();
21             bass.run();
22             Console.ReadKey();
23         }
24     }

 

posted @ 2021-09-07 17:09  小小林林  阅读(77)  评论(0编辑  收藏  举报