class Car
{
private string description;
private int wheels;
public Car(string description,int wheels)
{
this.description = description;
this.wheels=wheels;
}
public Car(string description)
{
this.description=description;
this.wheels=4;
}
}
因为两个构造函数初始化了相同的字段,所以为了简便可以使用构造函数初始化器来使一个构造函数调用另一个: