以前一直以为 B继承自A的话 他自身会复制一份 A的成员,今天才理解到他们两个是共用成员的,话不多说 上 代码
public class A { public int Num { get; set; } public A(int a) { this.Num = a * 100; } public void Test() { Console.WriteLine(this.Num); } } public class B : A { public B(int b) : base(b) { this.Num = b; } }
反汇编结果: