Linq search string word separate string -
i got list of string. want search inside , return new list. search value string (sentence). each word split space.
so, @ way search each string containing each word of sentence.
sample :
list = {"abcdef", "abc", "ab", "cd ab"} search "ab" => return list "abcdef", "abc", "ab", "cd ab" search "abc" => return list "abcdef", "abc" search "ab cd" => return list "abcdef","cd ab" its simple don't know how linq in single command.
if l.contains(list) where contains check every element of list.
that may simple, ask how. or maybe link post have not seen.
thank you
the tricky 1 last case of "ab cd".
var list = new list<string> {"abcdef", "abc", "ab", "cd ab"}; var result = list.where (w => "ab cd".split().all (s => w.contains(s)));
Comments
Post a Comment