ToList()方法

       //ToList()方法,翻译:把****转化为List集合。
      // 控制台试试:

string[] fruits = { "apple", "passionfruit", "banana", "mango","orange", "blueberry", "grape", "strawberry" }; List<int> lengths = fruits.Select(fruit => fruit.Length).ToList(); foreach (int length in lengths) { Console.WriteLine(length); } Console.ReadKey();
/* 5 12 6 5 6 9 5 10 */


来源: https://msdn.microsoft.com/zh-cn/library/bb342261(v=vs.110).aspx

posted @ 2016-12-08 14:29  hao_1234_1234  阅读(1707)  评论(0编辑  收藏  举报