【发布时间】:2010-12-25 09:32:49
【问题描述】:
请帮助我理解这段代码:
protected Customer()
{
}
在以下类中(示例 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
......
}
【问题讨论】:
-
感谢所有回答的人。很难选择接受的答案(抱歉只能是一个)。我对这段代码的怀疑与用于创建实例的多个构造函数的存在以及每个实例的特定目的有关。