简体   繁体   中英

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 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));

如果items是List<Item> ,则可以这样保存自己的ToList()调用:

var qry = items.FindAll(i => Codes.Contains(i.Code));

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM