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
Post a Comment