直接上代码范例:
Lambda:
List<Student> list =new List<Student>(){
new Student(){id= 1,Name =1},new Student(){id= 2,Name =2 },new Student(){id= 3,Name =3 }
new Student(){id= 4,Name =4},new Student(){id= 5,Name =5 },new Student(){id= 6,Name =6 }
}
选出id在(1,2)范围内的数据
var listIn= list.where(s=>new int[]{1,2}.Contatins(s.id));
Linq:
var list = from s in list where new int[]{1,2}.Contains(s.id) select u;
var listIn= list.where(s=>new int[]{1,2,3,4,5}.Contatins(s.id)).Skip(2).take(2);
输出:3,4