Compare String with split in contains - LINQ -


my requirement compare values in string list of string.

code:

string names = "prabha,karan";         list<string> presenter = new list<string> { "prabha", "joe", "hukm" };  bool presented = presenter.contains(names.split(',')); 

the above code throws error , here need find names presented in presenter(presenter has splited values of names).

you below:

var splitnames = names.split(','); bool presented = presenter.any(p => splitnames.contains(p)); 

edit:

if you're interested matches do:

var matches = presenter.where(p => splitnames.contains(p)) 

Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -