How to check if an array contains any item of another array
Using LINQ:
array1.Intersect(array2).Any()
Note: Using Any()
assures that the intersection algorithm stops when the first equal object is found.
C#3:
bool result = bar.Any(el => foo.Contains(el));
C#4 parallel execution:
bool result = bar.AsParallel().Any(el => foo.AsParallel().Contains(el));
Yes nested loops, although one is hidden:
bool AnyAny(int[] A, int[]B)
{
foreach(int i in A)
if (B.Any(b=> b == i))
return true;
return false;
}