【转载】list集合去重心得

List<int> ages = new List<int> { 21, 46, 46, 55, 17, 21, 55, 55 };
 
      IEnumerable<int> distinctAges = ages.Distinct();
 
      Console.WriteLine("Distinct ages:");
 
      foreach (int age in distinctAges)
      {
          Console.WriteLine(age);
      }
 
      /*
       This code produces the following output:
 
       Distinct ages:
       21
       46
       55
       17
      */

转载链接:http://www.sufeinet.com/forum.php?mod=viewthread&tid=10924#lastpost

  

posted @ 2015-07-21 11:20  段晨  阅读(121)  评论(0)    收藏  举报