设为首页收藏本站Access中国

Office中国论坛/Access中国论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

返回列表 发新帖
查看: 3872|回复: 2
打印 上一主题 下一主题

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

[复制链接]
跳转到指定楼层
1#
发表于 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. */
复制代码


分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享分享 分享淘帖 订阅订阅
2#
发表于 2014-3-26 17:44:19 | 只看该作者
学习了!赞个。。。顶

点击这里给我发消息

3#
发表于 2015-6-26 09:11:30 | 只看该作者
good
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-6-1 03:36 , Processed in 0.086168 second(s), 26 queries .

Powered by Discuz! X3.3

© 2001-2017 Comsenz Inc.

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