How to ignore the case sensitivity in List

前端 未结 11 882
旧时难觅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:01

    Simply, you can use LINQ query as like below,

    String str = "StackOverflow";
    int IsExist = Mylist.Where( a => a.item.toLower() == str.toLower()).Count()
    if(IsExist > 0)
    {
         //Found
    }
    

提交回复
热议问题