C# 编写简单的LINQ to Objects查询

// 编写简单的LINQ to Objects查询
// LinqtoObjects.cs
using System;
using System.Text;
using System.Linq;
using System.Collections.Generic;
namespace Ch19
{
    class LinqToObjects
    {
        static void Main( string[] args)
        {
            string[] names = { "James Huddleston" , "Pearly" , "Ami Knox" , "Rupali Agarwal"
                            , "Beth Christmas" , "Fabio Claudio" , "Vamika Agarwal"
                            , "Vidya Vrat Agarwal" };
            IEnumerable <string > emp = from name in names
                                      where name.Length <= 16
                                      select name;
            foreach ( var name in emp)
            {
                Console.WriteLine(name);
            }
            Console.ReadLine();
        }
    }
}
----------------
James Huddleston
Pearly
Ami Knox
Rupali Agarwal
Beth Christmas
Fabio Claudio
Vamika Agarwal


来自为知笔记(Wiz)


posted on 2013-08-26 01:16  伊利丹  阅读(237)  评论(0编辑  收藏  举报