并集---Union

集合的并集是合并两个集合的所有项,去重,如下图所示:

 
  1. List<int> ls1 = new List<int>() { 1,2,3,5,7,9 };
  2. List<int> ls2 = new List<int>() { 2,4,6,8,9,10};
  3. IEnumerable<int> unionLs = ls1.Union(ls2);
  4. foreach (int item in unionLs)
  5. {
  6. Console.Write("{0}\t", item);
  7. }

交集---Intersect

集合的交集是取集合的共同的项,如下图所示:

 
  1. List<int> ls1 = new List<int>() { 1,2,3,5,7,9 };
  2. List<int> ls2 = new List<int>() { 2,4,6,8,9,10};
  3. IEnumerable<int> intersectLs = ls1.Intersect(ls2);
  4. foreach (int item in intersectLs)
  5. {
  6. Console.Write("{0}\t",item);
  7. }

差集---Except

集合的差集是取在该集合中而不在另一集合中的所有的项,如下图所示:

List<int> ls1 = new List<int>() { 1,2,3,5,7,9 };
List<int> ls2 = new List<int>() { 2,4,6,8,9,10};
 
 
IEnumerable<int> exceptLs = ls1.Except(ls2);
foreach (int item in exceptLs)
{
Console.Write("{0}\t", item);
}

最新文章

  1. grunt集成自动启动
  2. [ZZ] 基于DirectX shader的Per-pixel lighting实现
  3. kill 非法用户
  4. bzoj3130
  5. mysql索引之唯一索引
  6. oracle之replace结合substr的使用
  7. Threads and Anonymous Classes in JAVA
  8. Monkey源码分析之事件注入
  9. python3中的一些小改动
  10. vue和react的介绍
  11. docker_macvlan
  12. 水平方向margin:auto
  13. java字符串拼接的几种方式
  14. ABAP基础二:ALV基础之ALV的简单编辑
  15. 6.redis的分布式锁
  16. python删除x天前文件及文件夹
  17. 中文latex去掉图片描述
  18. Atitit.获取验证码图片通过web
  19. 安装mysql8.0.11以及修改root密码、连接navicat for mysql。
  20. kafka运行错误:提示找不到或者无法加载主类错误解决方法

热门文章

  1. ios开发中如何调用苹果自带地图导航
  2. LeetCode 048 Rotate Image
  3. centos7安装Python的虚拟环境
  4. 课堂笔记【java JDBC】
  5. 转:Cookie详解
  6. PyQt(Python+Qt)学习随笔:QTableWidget的构造方法
  7. 函数与函数式编程(生成器 &amp;&amp; 列表解析 &amp;&amp; map函数 &amp;&amp; filter函数)-(四)
  8. DVWA SQL Injection Medium
  9. 个人项目(wc.exe)
  10. 使用Promise实现红绿灯交替重复亮