C# Linq 交集、并集、差集、去重http://blog.csdn.net/joyhen/article/details/39578325
2016-03-07 14:09
746 查看
using System.Linq;
List<string> ListA = new List<string>();
List<string> ListB = new List<string>();
List<string> ListResult = new List<string>();
ListResult = ListA.Distinct().ToList();//去重
ListResult = ListA.Except(ListB).ToList();//差集
ListResult= ListA.Union(ListB).ToList(); //并集
ListResult = ListA.Intersect(ListB).ToList();//交集
List<string> ListA = new List<string>();
List<string> ListB = new List<string>();
List<string> ListResult = new List<string>();
ListResult = ListA.Distinct().ToList();//去重
ListResult = ListA.Except(ListB).ToList();//差集
ListResult= ListA.Union(ListB).ToList(); //并集
ListResult = ListA.Intersect(ListB).ToList();//交集
相关文章推荐
- Dell R710 RAID1设置
- explain中的key_len
- Leet Code OJ 172. Factorial Trailing Zeroes [Difficulty: Easy]
- 简单总结RectF、Rect 和Matrix ,还有Paint的使用方法
- sleep和wait区别以及线程池简单实现示例
- You have new mail in /var/spool/mail/root
- UVA 11374(p329)----Airport Express
- mybaits where 语句中使用<if></if>注意事项
- 软件测试(二)之 Failure, Error & Fault
- 【软件测试】作业二:fault & error & failure
- Error (-17998): Failed to get [param not passed in call] thread TLS entry
- 如何在 Linux 上使用 Gmail SMTP 服务器发送邮件通知
- 如何在 Linux 上使用 Gmail SMTP 服务器发送邮件通知
- HUST 1606 Naive
- csu 1685: Entertainment Box【湖南省多校对抗赛3.6】multiset妙用
- installation failed since the device possibly has stale dexed jars that don't match the current vers
- Develop -- Training(十一) -- 通过NFC共享文件
- How the Main Thread works
- 严重: Failed to initialize end point associated with ProtocolHandler ["http-bio-8080"]
- FZU 1001 Duplicate Pair(简单题目)