-
- using System;
- using System.Collections.Generic;
- using System.Text;
- namespace ConsoleAppl
- {
- public class A
- {
- public virtual void Fun1(int i)
- {
- Console.WriteLine(i);
- }
- public void Fun2(A a)
- {
- a.Fun1(1);
- Fun1(5);
- }
- }
- //典型的基类重写实例
- public class B : A
- {
- public override void Fun1(int i)
- {
- base.Fun1(i + 1);
- }
- public static void Main()
- {
- B b = new B();
- A a = new A();
- a.Fun2(b);
- b.Fun2(a);
- Console.ReadKey();
- }
- }
- //class Program
- //{
- // static void Main(string[] args)
- // {
- // // Length 属性用于获取数组的长度。
- // // 注意,Length 是只读属性:
- // //Console.WriteLine("Number of command line parameters = {0}", args.Length);
- // //for (int i = 0; i < args.Length; i++)
- // //{
- // // Console.WriteLine("Arg[{0}] = [{1}]", i, args[i]);
- // //}
- // Console.ReadKey();
- // }
- //}
- }
12-24
06-26
05-26
08-22
03-14
03-04
05-09
“相关推荐”对你有帮助么?
-
非常没帮助
-
没帮助
-
一般
-
有帮助
-
非常有帮助
提交