编程语言
首页 > 编程语言> > [转载]c# Intersect 交集,Except 差集,Union 并集

[转载]c# Intersect 交集,Except 差集,Union 并集

作者:互联网

Intersect 交集,Except 差集,Union 并集
int[] oldArray = { 1, 2, 3, 4, 5 };
int[] newArray = { 2, 4, 5, 7, 8, 9 };
var jiaoJi = oldArray.Intersect(newArray).ToList();//2,4,5
var oldChaJi = oldArray.Except(newArray).ToList();//1,3
var newChaJi = newArray.Except(oldArray).ToList();//7,8,9
var bingJi = oldArray.Union(newArray).ToList();//1,2,3,4,5,7,8,9

https://blog.csdn.net/hb_ljj/article/details/100834889

标签:ToList,并集,c#,oldArray,Except,Union,newArray,var
来源: https://www.cnblogs.com/ufo233/p/15336710.html