How would I convert this to a lambda expression?
wondering if anyone can help. This works, but I was wondering how it would look in Lambda instead (Just curious !)
Codes is simply开发者_Python百科 an array of id's and each item has a code...
var qry = from i in items
where Codes.Contains(i.Code)
select i;
return qry.ToList();
Thanks Andrew.
return items.Where(i => Codes.Contains(i.Code)).ToList();
var qry = items.Where(i => Codes.Contains(i.Code));
If items is a List<Item>
, you can save yourself the ToList()
call like so:
var qry = items.FindAll(i => Codes.Contains(i.Code));
精彩评论