我正在将一个选中的列表框与以下 ling 绑定,以重新运行列表列表,但如果列表为空,我应该如何管理它?它在 ling 语句中引发异常,如果为 null,我应该为复选框设置什么
public List<dataObject> GetAllCustomItems(CategoryType currType, int mCategoryID)
{
List<dataObject> lst = null;
try
{
switch (currType)
{
case CategoryType.Dressing:
lst = (from xx in this.DressingItems
where xx.DressingInfo.CatID == mCategoryID
select new dataObject() {
ID = xx.DressingInfo.DressingID,
Name = xx.DressingInfo.Description,
Selected = xx.IsDefault
}).ToList();
break;
}
}
它抛出异常
Value cannot be null.
Parameter name: source