請幫我理解這一段代碼: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