| 用和子类继承父类的方式类似的“:”来调用(继承)父类的构造函数。 如果基类中定义了带参数的一个或者多个构造函数,则派生类中也必须定义至少一个构造函数,且派生类中的构造函数都必须通过base()函数“调用”基类中的某一个构造函数。
 复制代码        static void Main(string[] args)
        {
            B b = new B(1, 2, 3, 4);
            Console.WriteLine(b.ToString());
            Console.ReadLine();
            A a = b;
            Console.WriteLine(a.ToString());
            Console.ReadLine();
        }
         public class A
          {
              int i,j;
              public A(int a, int b)
              {
                   i = a;
                   j = b;
              }
              public override string ToString()
              {
                  return "i="+i+",j="+j+"";
              }
           }
         public class B:A
          {
            int d, c;
            public B(int x, int y, int z, int e):base(x,y)
             {
                d = z;
                c = e;
             }
            public new string ToString()
             {
                 return "d=" + d + ",c=" + c + "";
              }
           }
 |