IEnumerable是可枚举集合接口 IEnumerable<string> 泛型可枚举集合from s in names where s.Length == 5 orderby s select s.ToUpper(); //linq查询 这些是net3.0以上版本的代码如果本身net3.0以上版本,你还可以使用 匿名类型和lambda表达式
IEnumerable<string> 是接口, expr是string类型的集合,该接口以扩展方法的方式,实现了where、orderby 、 select等扩展方法! IEnumerable<string> expr = from s in names where s.Length == 5 orderby s select s.ToUpper();where、orderby 、 select 后面接受的是一个委托,例如 where 接受的是Func<string, bool>类型的委托也可以这样写: Func<string, bool> filter = delegate(string s) { return s.Length == 5; }; IEnumerable<string> expr =names.where(filter)........
IEnumerable<string> 泛型可枚举集合from s in names where s.Length == 5 orderby s select s.ToUpper(); //linq查询 这些是net3.0以上版本的代码如果本身net3.0以上版本,你还可以使用 匿名类型和lambda表达式
IEnumerable<string> expr = from s in names
where s.Length == 5
orderby s
select s.ToUpper();where、orderby 、 select 后面接受的是一个委托,例如 where 接受的是Func<string, bool>类型的委托也可以这样写:
Func<string, bool> filter = delegate(string s)
{
return s.Length == 5;
};
IEnumerable<string> expr =names.where(filter)........
IEnumerable <string> expr = Enumerable.Where(names, filter);