集合与lamdba

      List<int> iList = new List<int>() { 1, 2, 3, 4, 5 };
            List<int> iList2 = iList.ConvertAll<int>(i => (i + 5));
            /*
        foreach (int k in iList2)
           {
               Console.WriteLine(k.ToString());
           }
             * */
            iList2.ForEach(i => Console.WriteLine(i.ToString()));
            Console.ReadLine();

2

 static void Main()
    {
    List<int> list = new List<int>(new int[] { 19, 23, 29 });

    // Finds first element greater than 20
    int result = list.Find(item => item > 20);

    Console.WriteLine(result);
    }

3

     static void Main(string[] args)
        {
            List<int> iList = new List<int>() { 1, 2, 3, 4, 5 };
            List<int> iList2 = iList.FindAll(i => i > 3);

          iList2.ForEach(i => Console.WriteLine(i.ToString()));
  // List<int> iList2 =    iList.Where(i => i > 3).ToList<int>();
Console.ReadLine();
// 4,5 }

 

posted @ 2013-12-30 14:57  勾司程序员  阅读(177)  评论(0)    收藏  举报