linq用于实现了IEnumerable特性的类型的数组的操作。
linq一般的写法
int[] scores = new int[] { 97, 92, 81, 60 };
IEnumerablescoreQuery =
from score in scores
where score > 80
select score;
//msdn的例子
语句要查询出scores中大于80的分数。
from 通常用于声明变量,变量score是集合scores中的一个对象,
然后 where 用于判断,
最后select用于筛选出所有满足条件的对象。
上面的表达式也可以写成
var scoreQuery = scores.Where(s => s>80);