I have 2 IEnumerable<int>
IEnumerable<int> x;
IEnumerable<int> y;
What is the best best way to determine if any int in y is present in the x?
Currently I'm using:
return x.Intersect<int>(y).Count() > 0;
Would it be significantly faster to loop through and test each individually?
foreach (int i in x)
{
foreach (int j in y)
{
if (i == j) return true;
}
}
return false;
The lists are relatively light, with not more than 50 ints in x and 4 in y if that matters in the consideration.