1、构造函数的调用顺序是先调用System.Object,再按照层次结构由上向下进行,直到到达编译器要实例化的类为止
public abstract class GenericCustomer
{
private string name;
public GenericCustomer()
: base() // we could omit this line without affecting the compiled code
{
name = "<no name>";
}
class Nevermore60Customer : GenericCustomer
{
private uint highCostMinutesUsed;
// other methods etc.
}
2、
abstract class GenericCustomer
{
private string name;
public GenericCustomer(string name)
{
this.name = name;
}
class Nevermore60Customer : GenericCustomer
{
private string referrerName;
public Nevermore60Customer(string name)
: this(name, "<None>")
{ }
public Nevermore60Customer(string name, string referrerName)
: base(name)
{
this.referrerName = referrerName;
}
}
private uint highCostMinutesUsed;