Andrew Jocelyn <(E-Mail Removed)> wrote:
> I need to do a case insensitive search on a Generic list. I'm trying to use
> the BinarySearch method but I get a complier error "cannot convert from
> 'System.Collections.CaseInsensitiveComparer' to
> 'System.Collections.Generic.IComparer<string>' "
>
> List<string> list = new List<string>();
> list.Add(str1);
> list.Add(str2);
> list.Add(str3);
> int index = list.BinarySearch(otherstr, new CaseInsensitiveComparer());
>
> What's the correct procedure?
Use StringComparer.*IgnoreCase (where * is Ordinal, CurrentCulture or
InvariantCulture depending on your needs).
--
Jon Skeet - <(E-Mail Removed)>
Web site:
http://www.pobox.com/~skeet
Blog:
http://www.msmvps.com/jon_skeet
C# in Depth:
http://csharpindepth.com