How to ignore the case sensitivity in List

前端 未结 11 930
旧时难觅i
旧时难觅i 2020-11-30 09:46

Let us say I have this code

string seachKeyword = \"\";
List sl = new List();
sl.Add(\"store\");
sl.Add(\"State\");
sl.Add(\"STAM         


        
11条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-11-30 10:08

    You can apply little trick over this.
    Change all the string to same case: either upper or lower case

    List searchResults = sl.FindAll(s => s.ToUpper().Contains(seachKeyword.ToUpper()));

提交回复
热议问题