请帮我理解这一段代码:C#示例语法问题
protected Customer()
{
}
在下面的类(Model类从样品WPF MVVM应用程序):
public class Customer : IDataErrorInfo
{
#region Creation
public static Customer CreateNewCustomer()
{
return new Customer();
}
public static Customer CreateCustomer(
double totalSales,
string firstName,
string lastName,
bool isCompany,
string email)
{
return new Customer
{
TotalSales = totalSales,
FirstName = firstName,
LastName = lastName,
IsCompany = isCompany,
Email = email
};
}
protected Customer() // it is what I asked about
{
}
#endregion // Creation
......
}
感谢所有回答。很难选择被接受的答案(对不起,它只能是一个)。我对这段代码的怀疑与创建实例的几个构造函数的存在以及每个构造函数的特定目的有关。 – rem 2009-12-10 20:10:34