Intersection of two string array (ignore case)

.net, c#, intersection, linq

Solution

How about an `Enumerable.Intersect` and `StringComparer` combo:

// other options include StringComparer.CurrentCultureIgnoreCase
// or StringComparer.InvariantCultureIgnoreCase
var results = array1.Intersect(array2, StringComparer.OrdinalIgnoreCase);

Problem

I have two arrays: ``` string[] array1 = { "Red", "blue", "green", "black" }; string[] array2 = { "BlUe", "yellow", "black" }; ``` I need only the matching strings in one array (ignoring case). Result should be: ``` string[] result = { "blue", "black" } or { "BlUe", "black" }; ```

Original source