I have a
List words = new List {\"word1\", \"word2\", \"word3\"};
And i want to check using linq if my string
While most of the solutions presented are functional (the all call Contains
, which will give you the desired solution), if the list and the text are large, you may have performance issues.
From the problem that was stated, I'd think that you call a word anything between spaces or any other divisor. So, I'd recommend you split your myText
into a list of words, and compare each one of them to you list of words, now using contains.
It's way more complex, of course; You'd have to make sure split words correctly -- but with larger strings (for example, a text file) there might be some performance gain.