I need to find the values in array A that don't exist in array B
A = {1,2,3,4,5,6,7,8,9,10}
B = {1,2,3,7,8}
result = {4,5,6,9,10}
Can anyone give me any pointers?
I need to find the values in array A that don't exist in array B
A = {1,2,3,4,5,6,7,8,9,10}
B = {1,2,3,7,8}
result = {4,5,6,9,10}
Can anyone give me any pointers?
Using LINQ:
var C = A.Except(B);
or, if you want it as an array:
int[] C = A.Except(B).ToArray();
var arrayA = new [] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
var arrayB = new [] { 1, 2, 3, 7, 8 };
var result = arrayA.Except(arrayB);
public void Linq52()
{
int[] numbersA = { 0, 2, 4, 5, 6, 8, 9 };
int[] numbersB = { 1, 3, 5, 7, 8 };
IEnumerable<int> aOnlyNumbers = numbersA.Except(numbersB);
Console.WriteLine("Numbers in first array but not second array:");
foreach (var n in aOnlyNumbers)
{
Console.WriteLine(n);
}
}