我有以下项目Lambda多个条件来验证对象列表中的列表?
List<person> lst = new List<person>()
lst.Add(new person(){ name="abc", age="24" });
lst.Add(new person(){ name="xyz", age="25" });
lst.Add(new person(){ name="zxc", age="28" });
lst.Add(new person(){ name="wer", age="38" });
List<string> strlst = new List<string>();
strlst.Add("abc");
strlst.Add("zxc");
现在我确认名单
lst.Exists(a => strlst.Contains(a.name))
我如何验证整个列表,如果它包含“ABC and
xyz`两者组成的列表?
请注意,这是一个相当低效的操作,因为您正在为您搜索的每个字符串执行所有人员的线性搜索,所以它不能很好地适用于大数据集。对于小数据集,它会很好。 – Servy 2013-02-21 14:54:40
你能提出任何其他方法吗? – Pravin 2013-02-21 15:05:14
@Pravin当然,请看我的答案。 – Servy 2013-02-21 15:08:39