Office中国论坛/Access中国论坛

标题: C# List.Distinct简单去重方法Demo [打印本页]

作者: 闻启学    时间: 2014-3-26 17:19
标题: C# List.Distinct简单去重方法Demo
  1. List<int> ages = new List<int> { 21, 46, 46, 55, 17, 21, 55, 55 };

  2. IEnumerable<int> distinctAges = ages.Distinct();

  3. Console.WriteLine("Distinct ages:");

  4. foreach (int age in distinctAges)
  5. {
  6.     Console.WriteLine(age);
  7. }

  8. /*
  9. This code produces the following output:

  10. Distinct ages:
  11. 21
  12. 46
  13. 55
  14. 17
  15. */
复制代码



作者: cc1027cc    时间: 2014-3-26 17:44
学习了!赞个。。。顶
作者: Alashome    时间: 2015-6-26 09:11
good




欢迎光临 Office中国论坛/Access中国论坛 (http://www.office-cn.net/) Powered by Discuz! X3.3