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!
Here's what worked:
IEnumerable<string> differenceQuery = inputTable.Except(strArrList,
StringComparer.OrdinalIgnoreCase);
Used StringComparer
instead of StringComparison
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With