两个数组,如何找出相同或者不同的元素?请看代码:
string[] arr1 = new[] { "1", "2", "3", "4", "5" };
string[] arr2 = new[] { "1", "3", "5" };
var sameArr = arr1.Intersect(arr2).ToArray(); //找出相同元素(即交集)
var diffArr = arr1.Where(c => !arr2.Contains(c)).ToArray();//找出不同的元素(即交集的补集)