StephenCleary / Comparers

The last comparison library you'll ever need!
MIT License
427 stars 33 forks source link

Equality String Comparer Ignore Case #9

Closed FutureTD closed 6 years ago

FutureTD commented 6 years ago

Is there a way to make the string equality comparer case insensitive using the StringComparison.OrdinalIgnoreCase, I would prefer to no have to do .ToUpper() or .ToLower() if possible.

StephenCleary commented 6 years ago

Sure; you can pass it as the second parameter to a key comparer.

Using the classic Person example, you can do this:

ComparerBuilder.For<Person>().OrderBy(p => p.LastName, StringComparison.OrdinalIgnoreCase);