To go with John's explanation, here is (hopefully) an equivalent sample with outputs:
static void Main(string[] args) { int[] i = new int[] { 1, 2, 3, 4, 5 }; int[] j = new int[] { 5, 6, 7, 8, 9 }; int[] k = new int[] { 0, 6, 7, 8, 9 }; bool jContainsI = i.Any(iElement => j.Contains(iElement)); bool kContainsI = i.Any(iElement => k.Contains(iElement)); Console.WriteLine(jContainsI);
Basically, any element i in j or k . This assumes your parameters x and y are collections of some variety.
Intersection is a valid alternative here:
bool iIntersectsJ = i.Intersect(j).Any(); // true bool iIntersectsK = i.Intersect(k).Any(); // false
source share