顺序如下:
1.子类的内联字段
2.子类的静态构造函数
3.父类的内联字段
4.父类的静态构造函数
5.父类的构造函数
6.子类的构造函数
7.子类的方法
public class A{public static string a1="A0";static A(){Console.WriteLine("父类内联字段:"+a1);Console.WriteLine("父类静态构造函数A1");}public A(){Console.WriteLine("父类构造函数A2");}public virtual void a3(){Console.WriteLine("a3");}}public class B:A{public static string b1="B0";static B(){Console.WriteLine("子类内联字段:"+b1);Console.WriteLine("子类静态构造函数B1");}public B(){Console.WriteLine("子类构造函数B2");}public override void a3(){Console.WriteLine("子类方法b3");}}private static async Task Main(string[] args){B B=new B();B.a3();}
执行结果如下: