[size=medium][color=blue]派生类中定义带一个参数的构造函数(方法一)[/color][/size]
[size=medium][color=blue]派生类中定义带一个参数的构造函数(方法二)[/color][/size]
public class GenericCustomer
{
private string name;
public GenericCustomer()
{ }
public GenericCustomer(string name)
{
this.name = name;
}
}
public class NevermoreCustomer : GenericCustomer
{
public NevermoreCustomer()
{ }
}
[size=medium][color=blue]派生类中定义带一个参数的构造函数(方法二)[/color][/size]
public class GenericCustomer
{
private string name;
public GenericCustomer(string name)
{
this.name = name;
}
}
public class NevermoreCustomer : GenericCustomer
{
private string age;
//派生类中定义带一个参数的构造函数 base(name)调用基类中的构造函数
public NevermoreCustomer(string name)
: base(name)
{ }
派生类中定义带一个参数的构造函数 this(name, "none")
//public NevermoreCustomer(string name)
// : this(name, "none")
//{ }
//派生类中定义带二个参数的构造函数
public NevermoreCustomer(string name, string age)
: base(name)
{
this.age = age;
}
}