.net - Linq query to filter a list of strings in Observable collection -


from observable collection want filter items names aaa,bbb,ccc,ddd,eee. how this?

public class item { public string itemname {get; set;} public int itemnumber {get; set;} }  public observablecollection<item> _items;  public list<string> searchitems = new list<string>(5); searchitems.add("aaa"); searchitems.add("bbb"); searchitems.add("ccc"); searchitems.add("ddd"); searchitems.add("eee"); 

i tried bit in linq.. dont know how list..

var filtereditems = item in _items                     _items.any(x => x.itemname == "aaa")                     select x; 

you can use contains;

var filtereditems = item in _items                     _items.any(x => searchitems.contains(x.itemname))                     /*select x;*/                     select item; 

Comments

Popular posts from this blog

android - Why am I getting the message 'Youractivity.java is not an activity subclass or alias' -

python - How do I create a list index that loops through integers in another list -

c# - “System.Security.Cryptography.CryptographicException: Keyset does not exist” when reading private key from remote machine -