C#构造函数里的base和this
来源:互联网 发布:微信域名防封跳转系统 编辑:程序博客网 时间:2024/06/06 06:53
父类的构造函数总是在子类之前执行的。
public class BaseCircle { public BaseCircle() { Console.WriteLine(" no arguments base constructor!!!"); } public BaseCircle(double arg) { Console.WriteLine("double arg base constructor!!!"); } } public class SubCircle : BaseCircle { public SubCircle():base() { Console.WriteLine("sub class no argument constructor,actually call base constructor !!!"); } public SubCircle(double a):base(a) { Console.WriteLine("sub class with argument, actually call base double constructor!!!"); } public SubCircle(int k):this(1,2) { Console.WriteLine("sub class with argument int k, actually call sub class constructor int i & j !!!"); } public SubCircle(int i,int j) { Console.WriteLine("sub class with int i&j argument!!!!"); } }static void Main(string[] args) { SubCircle s1 = new SubCircle(); SubCircle s2 = new SubCircle(1.1); SubCircle s3 = new SubCircle(1);}输出结果: no arguments base constructor!!!sub class no argument constructor,actually call base constructor !!!double arg base constructor!!!sub class with argument, actually call base double constructor!!! no arguments base constructor!!!sub class with int i&j argument!!!!sub class with argument int k, actually call sub class constructor int i & j !!!
- C#构造函数里的base和this的区别
- C#构造函数里的base和this的区别
- C#构造函数里的base和this的区别
- C#构造函数里的base和this的区别
- C#构造函数里的base和this的区别
- C#构造函数里的base和this
- .Net C#语法 构造函数中this和base
- .Net C#语法 构造函数中this和base
- c# base和this在构造函数中的应用
- 构造函数中base和this的用法与区别
- 构造函数中base和this的用法与区别
- C# base和this
- C# base和this
- C# base和this
- C# base和this
- C# base和this
- C# base和this
- C# base和this
- 英特尔开源OpenGL驱动快于苹果驱动
- 如何查看linux的版本信息
- 西安青松科技面试题
- XCode环境变量及路径设置
- ⑥Windows系统下Django1.4 --设计URL、view、template、404、505
- C#构造函数里的base和this
- warning C4603: “_WINDLL”: 未定义宏或在预编译头使用后定义发生改变
- 阿里80亿贷款细节曝光 并购背后图谋大数据
- webclient在访问期间出现 异常,报错! 无法发送具有此谓词类型的内容正文。
- 你所应该知道的Android设计
- Android 中的 Service 全面总结
- 阻塞和非阻塞
- HTTP协议
- AMD推出Temash APU处理器 进军平板市场