What Was I Thinking?

Follies & Foils of .NET Development
posts - 95 , comments - 352 , trackbacks - 0

Performing Case-Insensitive joins using EXCEPT operator in LINQ

   1:   var daysOfWeek = new[] { "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" };
   2:   var workDays = daysOfWeek.Except( new []{ "SUNDAY", "SaTURdaY"}); // Performs a case sensitive search and yields Sunday,Monday - Saturday. 
   3:  workDays = daysOfWeek.Except(new[] { "SUNDAY", "SaTURdaY" },StringComparer.OrdinalIgnoreCase); // Performs a case insensitive search and yields Monday-Friday

 

The except operator takes a comparer that tells it how to evaluate the two lists.  Nice one!

Print | posted on Wednesday, October 26, 2011 1:20 AM |

Feedback

Gravatar

# re: Performing Case-Insensitive joins using EXCEPT operator in LINQ

Thanks for your suggestion. It is helps to me.
11/26/2015 5:05 AM | Ranajit Bhowmick
Post A Comment
Title:
Name:
Email:
Comment:
Verification:
 

Powered by: