Ken H

Ken H

  • NA
  • 646
  • 354.9k

using LINQ query two (or more) collections

Feb 25 2014 10:41 PM
 Hello friend,
   How to change the following matching algorithm is LINQ?
 
static void NotExist(int[] a, int[] b) {
bool YES;
Console.WriteLine("The 'b' array element does not exist:");
for (int i = 0; i < a.Length; i++){
YES = false;
for (int j = 0; j < b.Length; j++){
if (a[i] == b[j]){
YES = true;
break;
 }
}
if (!YES) Console.Write("{0},",a[i]);
}
 
Console.Write("\b ");
}
static void Main(string[] args){
 
int[] a = new int[5] { 1, 22, 39, 6, 10 };
int[] b = new int[5] { 2, 4, 39, 10, 89 };
NotExist(a, b);
Console.ReadKey();
}
 
Thanks. 

Answers (2)