2 回答
TA贡献1719条经验 获得超6个赞
List<int> myint = new List<int>();
myint.Add(3);
myint.Add(4);
myint.Add(5);
myint.Add(6);
List<int> myint2 = new List<int>();
myint2.Add(3);
myint2.Add(4);
var resint = myint.Except(myint2);
foreach (int item in resint)
{
Console.Write(item);
}
TA贡献2041条经验 获得超4个赞
使用 LINQ 查询表达式
IEnumerable<SelectListItem> stores =
from store in database.Stores
where store.CompanyID == curCompany.ID
select new SelectListItem { Value = store.Name, Text = store.ID };
ViewBag.storeSelector = stores;
或使用 LINQ 扩展方法和 lambda 表达式
IEnumerable<SelectListItem> stores = database.Stores
.Where(store => store.CompanyID == curCompany.ID)
.Select(store => new SelectListItem { Value = store.Name, Text = store.ID });
ViewBag.storeSelector = stores;
添加回答
举报