Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

list with distinct and StringComparison.OrdinalIgnoreCase

Tags:

c#

I have list, how can I get distinct values?

IList<string> words = new List<string> { "A", "b", "a" };
var distinctWords = words.Distinct(StringComparison.OrdinalIgnoreCase);

this gives me error: Distinct has some invalid arguments.

like image 339
michael Avatar asked Apr 17 '14 17:04

michael


1 Answers

You need: StringComparer.OrdinalIgnoreCase not StringComparison.OrdinalIgnoreCase

IList<string> words = new List<string> { "A", "b", "a" };
var distinctWords = words.Distinct(StringComparer.OrdinalIgnoreCase);
like image 127
Habib Avatar answered Sep 30 '22 11:09

Habib