【发布时间】:2010-12-16 02:34:52
【问题描述】:
两种初始化中哪一种更好?
public class ServiceClass
{
private DataManager dataManager = new DataManager();
private Dictionary<string, string> stringDictionary = new Dictionary<string, string>();
private Dictionary<string, DateTime> timeDictionary = new Dictionary<string, DateTime>();
public ServiceClass()
{
//other object creation code
}
}
或
public class ServiceClass
{
private DataManager dataManager;
private Dictionary<string, string> stringDictionary;
private Dictionary<string, DateTime> timeDictionary;
public ServiceClass()
{
dataManager = new DataManager();
stringDictionary = new Dictionary<string, string>();
timeDictionary = new Dictionary<string, DateTime>();
//other object creation code
}
}
【问题讨论】:
标签: c# .net coding-style