How to ignore the case sensitivity in List

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

    Below method will search your needed keyword and insert all searched items into a new list and then returns new list.

    private List serchForElement(string searchText, list ListOfitems)
    {            
        searchText = searchText.ToLower();
        List Newlist = (from items in ListOfitems
                             where items.ToLower().Contains(searchText.ToLower())
                             select items).ToList(); 
    

    return Newlist; }

提交回复
热议问题