score:19

Accepted answer

Borrowing a similar solution form here:

string[] result = {"hello there", "héllo there","goodbye"};

string word = "héllo";

var compareInfo = CultureInfo.InvariantCulture.CompareInfo;

var filtered = result.Where(
      p => compareInfo.IndexOf(p, word, CompareOptions.IgnoreNonSpace) > -1);

score:-1

You want to use the StringComparison.InvariantCultureIgnoreCase enum.

Source https://msdn.microsoft.com/en-us/library/system.stringcomparison(v=vs.110).aspx

filtered = result.Contains(word, StringComparison.InvariantCultureIgnoreCase);

However this is only going to work with LinqToObject. If you are using LinqToSQL or LinqToEntityFramework or LinqToNHibernate, this will not work.


Related Articles