派生类创建实例时,程序路径

时间:2014-03-05 17:53:21   收藏:0   阅读:449
bubuko.com,布布扣
路径:
派生类字段-->派生类构造函数之前-->被继承类字段-->被继承类构造函数-->被继承类构造函数
实例:
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
bubuko.com,布布扣

派生类创建实例时,程序路径,布布扣,bubuko.com

原文:http://www.cnblogs.com/fang-beny/p/3581447.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!