【发布时间】:2012-12-18 17:51:32
【问题描述】:
当collection属性(类型为“IList”或Array)时,如果没有元素,它应该为null还是应该表示为一个空的collection(即长度为零)
例如
public class Teacher
{
public List<Student> Students = null // to represent absence of items
}
或
public class Teacher
{
public List<Student> Students = new List<Student>() // Initialize the collection.
}
这方面的最佳做法是什么。
【问题讨论】: