c# - check a string array from a list contains a string from another list or vice versa -


is there easy way using linq?

i want check , return true or false, whether string list1 contains string array1. in below example string2value , want return true.

also want check whether array1 contain string list1. string1blah , return true well. thanks!

list<string> list1 = new list<string>{"string1","string2value"};  string[] array1 = new string[2] {"string1blah","string2"}; 

i have couple of versions, not work time.

array1.tolist().any(a=>list1.contains(a)) list1.any(l=>array1.tolist().contains(l)) 

you can try this:

var result= list1.where(s=>array1.any(s1=>s.contains(s1))); 

per each string in list1, see if there element in array1 contained in s string.


Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -