test

来源:互联网 发布:淘宝的数字暗语大全 编辑:程序博客网 时间:2024/04/30 09:55
    1. using System;
    2. using System.Collections.Generic;
    3. using System.Text;
    4. namespace ConsoleAppl
    5. {
    6.     public class A
    7.     {
    8.         public virtual void Fun1(int i)
    9.         {
    10.             Console.WriteLine(i);
    11.         }
    12.         public void Fun2(A a)
    13.         {
    14.             a.Fun1(1);
    15.             Fun1(5);
    16.         }
    17.     }
    18.     //典型的基类重写实例
    19.     public class B : A
    20.     {
    21.         public override void Fun1(int i)
    22.         {
    23.             base.Fun1(i + 1);
    24.         }
    25.         public static void Main()
    26.         {
    27.             B b = new B();
    28.             A a = new A();
    29.             a.Fun2(b);
    30.             b.Fun2(a);
    31.             Console.ReadKey();
    32.         }
    33.     } 
    34.     //class Program
    35.     //{
    36.     //    static void Main(string[] args)
    37.     //    {
    38.     //        // Length 属性用于获取数组的长度。
    39.     //        // 注意,Length 是只读属性:
    40.     //        //Console.WriteLine("Number of command line parameters = {0}", args.Length);
    41.     //        //for (int i = 0; i < args.Length; i++)
    42.     //        //{
    43.     //        //    Console.WriteLine("Arg[{0}] = [{1}]", i, args[i]);
    44.     //        //}
    45.     //        Console.ReadKey();
    46.     //    }
    47.     //}
    48. }
原创粉丝点击