Lambda statement for finding sub-string in a string from list of strings [closed]

bool contains = list.Any(yourString.Contains);

This is searching for substrings, so it doesn’t compare “words”.

Here is a version that ignores the case:

bool contains = list.Any(s => yourString.IndexOf(s, StringComparison.CurrentCultureIgnoreCase) >= 0);

Leave a Comment