已知 在JAVA程序中,构造器的重载可以写成以下形式
在一个类里面:
public class aaaa {
//两个参数构造器
public aaaa(String name,String color){
this.name=name;
this.color=color;
}
//三个参数构造器
public aaaa(String name,String color,double weight)
{
this(name,color); //这句就是调用上面2个参数的构造器
this.weight=weight;
}
}但是在C#中,这种调用却不被允许,如果不想把属性再一一写出来,请问有什么方式能代替吗?
在一个类里面:
public class aaaa {
//两个参数构造器
public aaaa(String name,String color){
this.name=name;
this.color=color;
}
//三个参数构造器
public aaaa(String name,String color,double weight)
{
this(name,color); //这句就是调用上面2个参数的构造器
this.weight=weight;
}
}但是在C#中,这种调用却不被允许,如果不想把属性再一一写出来,请问有什么方式能代替吗?
解决方案 »
- 求助,c# winform引用dll文件的奇怪问题
- 一个让人蛋疼的面试题啊
- 显示 WORD 到本窗口
- 在Asp中用Server.CreateObject建立的对象 现用 C# 怎么建立 呀?
- 关于XML的简单问题,在线等待,解决马上结贴!
- 邮件系统[支持POP3,SMTP],请各位多提宝贵意见!!!
- MDI子窗体 的 相关问题,估计大家已经遇到
- 【什么问题?】不可访问“System.Windows.Forms.Control.text”,因为它受保护级别限制!!
- 用XPath查询XML 文件能不能不区分大小写
- 请问:用SqlConnection,SqlCommand类与ADO.NET访问数据库有什么不同?
- 请问如何在窗体应用程序中写一个方法不影响窗体的运行?
- C#导出Excel文件时出现问题.帮忙解决下
public aaaa(String name, String color, double weight):this(name, color)
{
this.weight = weight;
}