当还使用自动属性时,是否有办法使用收集初始值设定项?具有自动属性的收集初始值设定程序
// Uses collection initializer but not automatic properties
private List<int> _numbers = new List<int>();
public List<int> Numbers
{
get { return _numbers; }
set { _numbers = value; }
}
// Uses automatic properties but not collection initializer
public List<int> Numbers { get; set; }
// Is there some way to do something like this??
public List<int> Numbers { get; set; } = new List<int>();
[默认值自动属性的可能重复](http://stackoverflow.com/questions/4691888/automatic-property-with-default-value) – AakashM 2011-04-21 20:11:12