c# - Find items in list where word exist and ignor special chars -


i have list of myitems:

my item  {    string name;    int age;  }   list<myitem> list = new list<myitem>(); list.add(new test("name", 2)); list.add(new test("ŚćĄa", 4)); list.add(new test("may nĄmĄa bb" , 7)); list.add(new test("may maa cc" , 7)); 

for :

var newlist = list.where(m => m.name.tolower().contains(texttosearch.tolower())).tolist(); 

i can ignore lower , upper case, how ignore special chars ĄĆŚ , when set texttosearch = "aa"; item two, 3 , four.

but when set texttosearch = "Ąa"; i'd item 2 , four

try this:

list.where(m =>      cultureinfo.invariantculture.compareinfo.indexof(         m.name,          texttosearch,          compareoptions.ignorenonspace | compareoptions.ignorecase) > -1 ).tolist(); 

two, 3 , 4 listed.


Comments

Popular posts from this blog

Payment information shows nothing in one page checkout page magento -

tcpdump - How to check if server received packet (acknowledged) -