Let's say I have List<string> that looks like this:
- Apple
- Pear
- Peach
- Plum
Then in a single string, if I have:
I would like to eat a pear today
(Ignore case.) In that case I I would want true because pearis found both in the list and in the string. But if I had a string:
I would like to eat a strawberry today
Then I would get false because none of the List<string>'s are found in the sentence.
I've been playing around with various things like:
string result = Fruits.FirstOrDefault(s => s.IndexOf(sentence) > 0);
Where Fruits is the List<string> and sentence is the other string. Not nailing it.
true\falseas result, you can use it likestring result = Fruits.Any(s => s.IndexOf(sentence) > 0);string result = Fruits.Any(s => sentence.IndexOf(s) > -1);