case:
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ConsoleApplication3 { public class A { public A() { Console.WriteLine("A"); } public A(int x) { Console.WriteLine("A+"); } } public class B : A { public B():base(6) { Console.WriteLine("B"); } public B( int x):this() { Console.WriteLine("B+"); } } class Program { static void Main(string[] args) { B test = new B(4); Console.ReadKey(); } } }
运行结果是:A+ B B+
初始化是首先找到最顶的构造函数,一步步实现初始化。