日期:2014-05-17 浏览次数:20978 次
bool A=false, B=false;
List<Person> list = new List<Person>() {
new Person(){ Id=1,Count=2,Name="xiaoma"},
new Person(){ Id=2,Count=6,Name="xiaoma"},
new Person(){ Id=3,Count=9,Name="xiaoma"},
};
if (A)
{
list = list.Where(a=>a.Count>3).ToList();//选出count>3
}
if (B)
{
list = list.Where(a => a.Name.Equals("xiaoma")
------解决方案--------------------
a.Name.Equals("xiaowang")).ToList();//选出name=xiaoma 或者xiaowang的记录
}