How to check if any words in a list contain a partial string?

c#

Solution

You can use the Enumerable.Any method:

bool contained = alist.Any( l => l.Contains("somestring") );

This is checking each element using String.Contains, which checks substrings. You previously were using `ICollection<string>.Contains()`, which checks for a specific element of the list.

Problem

``` var list=alist.Contains("somestring") ``` this matches whole string, how to see if any word in list has a substring matching "somestring"?

Original source