How to ignore the case sensitivity in List

Use Linq, this adds a new method to .Compare

using System.Linq;
using System.Collections.Generic;

List<string> MyList = new List<string>();
MyList.Add(...)
if (MyList.Contains(TestString, StringComparer.CurrentCultureIgnoreCase)) {
    //found
} 

so presumably

using System.Linq;
...

List<string> searchResults = sl.FindAll(s => s.Contains(seachKeyword, StringComparer.CurrentCultureIgnoreCase));  

Leave a Comment