Bob Gatto Bob Gatto - 1 month ago 9x
C# Question

How do I find equal values in multiple arrays?

In my program I ccould wind up with 2 or more arrays. In each array there are no duplicate values in a single array and the length of each array could be different.

What is the easy way to find if a value in array1 is equal to a value in array2 and equal to a value array3 and so on?


You can use LINQ. If you just need to know, if there are duplicates:

array1.Any(value1 => array2.Any(value2 => value2.Equals(value3)) &&array3.Any(....))

If you need the duplicated values itself, replace the first Any behind array 1 with a Where.