当前第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>的并集与交集以及差集解析的详细内容!
返回前面的内容
相关阅读 >>
oracle clob字段过长保存出错改如何解决?
.net core中如何使用entity framework操作postgresql?
c#中匿名对象与var以及动态类型 dynamic的详解
linux下搭建.net core环境方法步骤
c#实现杨辉三角的示例
javascript client 如何获取 telerik radgrid的值
c#实现与现有.net事件桥接的简单代码
死锁的概念与死锁的条件
介绍c#中的接口
unity c# getsavefilename()的实例详解
更多相关阅读请进入《csharp》频道 >>
清华大学出版社
作者:[美]克里斯琴·内格尔(Christian Nagel)著。出版时间:2019年3月。
转载请注明出处:木庄网络博客 » C#中关于List<T>的并集与交集以及差集解析