当前第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》频道 >>
清华大学出版社
作者:[美]克里斯琴·内格尔(Christian Nagel)著。出版时间:2019年3月。
转载请注明出处:木庄网络博客 » C#中关于List<T>的并集与交集以及差集解析