string[] names = { "Burke", "Connor", "Frank", 
                       "Everett", "Albert", "George", 
                       "Harris", "David" };    IEnumerable<string> expr = from s in names 
                              where s.Length == 5
                               orderby s
                            select s.ToUpper();IEnumerable<string> expr 是什么意思?这样定义的吗?这是什么语法?

解决方案 »

  1.   

    这是Linq语法...返回一个泛型可枚举集合...
      

  2.   

    http://msdn.microsoft.com/zh-cn/library/kwtft8ak.aspx
      

  3.   

    http://msdn.microsoft.com/zh-cn/library/0x6a29h6.aspx
      

  4.   

    IEnumerable是可枚举集合接口
    IEnumerable<string> 泛型可枚举集合from s in names where s.Length == 5 orderby s select s.ToUpper(); //linq查询 这些是net3.0以上版本的代码如果本身net3.0以上版本,你还可以使用 匿名类型和lambda表达式
      

  5.   

     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)........
      

  6.   

    还可以这样写:
    IEnumerable <string> expr = Enumerable.Where(names, filter);