如何使用linq查询LIST [英] how to query LIST using linq

查看:62
本文介绍了如何使用linq查询LIST的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我将人员类实例添加到列表中,然后需要使用linq查询列表.

Suppose if I add person class instance to list and then I need to query the list using linq.

List lst=new List();
lst.add(new person{ID=1,Name="jhon",salary=2500});
lst.add(new person{ID=2,Name="Sena",salary=1500});
lst.add(new person{ID=3,Name="Max",salary=5500});
lst.add(new person{ID=4,Name="Gen",salary=3500});

现在我想用linq查询上面的列表.请指导我提供示例代码.

Now I want to query the above list with linq. Please guide me with sample code.

推荐答案

我也建议 LinqPad 作为无论是高级用户还是初学者,都可以使用Linq轻松解决问题.

I would also suggest LinqPad as a convenient way to tackle with Linq for both advanced and beginners.

示例:

这篇关于如何使用linq查询LIST的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆