I have two lists and I want to compare them and get the differences, while ignoring any case differences.
I have used the following code to get the differences between the two lists but it does not ignore case differences.
IEnumerable<string> diff = list1.Except(list2);
List<string> differenceList = diff.ToList<string>();
I tried this:
IEnumerable<string> diff = list1.Except(list2, StringComparison.OrdinalIgnoreCase);
but Except does not seem to be having a string case check of that sort (so error). I'm hoping there's a work around.
Try this :)
List<string> except = list1.Except(list2, StringComparer.OrdinalIgnoreCase).ToList();
Worked for me!