C#中关于List<T>的并集与交集以及差集解析


当前第2页 返回上一页

1

2

3

4

5

6

7

8

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> intersectLs = ls1.Intersect(ls2);foreach (int item in intersectLs)

{

    Console.Write("{0}\t",item);

}

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


1

2

3

4

5

6

7

8

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);

}

以上就是C#中关于List<T>的并集与交集以及差集解析的详细内容!

返回前面的内容

相关阅读 >>

在.net core类库中使用ef core迁移数据库到sql server的方法_实用技巧

c# 中十进制与二进制、十六进制、八进制转换详解

.net实现微信js-sdk分享功能代码展示

javascript client 如何获取 telerik radgrid的值

c#中委托和匿名委托的具体介绍

c#中关于async与await的使用详解

死锁的概念与死锁的条件

c#中list的用法

c#开发微信门户及应用(一)之微信接口的如何使用(图)

文件事物管理transactional file manager的实例详解

更多相关阅读请进入《csharp》频道 >>




打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...