设为首页收藏本站Access中国

Office中国论坛/Access中国论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

返回列表 发新帖
查看: 3662|回复: 2

C# List.Distinct简单去重方法Demo

[复制链接]
发表于 2014-3-26 17:19:52 | 显示全部楼层 |阅读模式
  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. */
复制代码


发表于 2014-3-26 17:44:19 | 显示全部楼层
学习了!赞个。。。顶

点击这里给我发消息

发表于 2015-6-26 09:11:30 | 显示全部楼层
good
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|站长邮箱|小黑屋|手机版|Office中国/Access中国 ( 粤ICP备10043721号-1 )  

GMT+8, 2024-3-29 22:37 , Processed in 0.079083 second(s), 27 queries .

Powered by Discuz! X3.3

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表