日期:2014-05-17 浏览次数:21048 次
int[] A=new int[]{1,2,3,4,5,6,7,8,9,10};
int[] B=new int[]
{2,3,4,5,6,6,19,20,21,21};
int[] C=A.Except(B).Union(B.Except(A)).ToArray();
//int[] D = A.Union(B).Except(A.Intersect(B)).ToArray();
var A = new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
var B = new int[] { 2, 3, 4, 5, 6, 6, 19, 20, 21, 21 };
var x = new List<int>();
foreach (var a in A)
{
if (!x.Contains(a))
x.Add(a);
}
foreach (var b in B)
{
if (!x.Contains(b))
x.Add(b);
else
x.Remove(b);
}
var C = x.ToArray();