开发者

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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜