路径:
派生类字段-->派生类构造函数之前-->被继承类字段-->被继承类构造函数-->被继承类构造函数
实例:
public class A { int m = 4; public A() { PrintFields(); } public virtual void PrintFields() { } } public class B : A { int x = 1; int y; public B() { y = -1; } public override void PrintFields() { Console.WriteLine("x={0},y={1}", x, y); } }

结果:
x=1,y=0

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-10-21
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-18
  • 2022-02-27
猜你喜欢
  • 2021-10-25
  • 2022-12-23
  • 2022-02-25
  • 2022-12-23
  • 2021-07-19
  • 2022-12-23
  • 2021-06-26
相关资源
相似解决方案