C#: LINQ – Any() to test a collection

Please see my other LINQ articles.

Use Any() to test an entire collection.

In this article I’ll demonstrate how to use Any() to determine any object in the collection matches a search predicate.

First, I’ll get a collection of static People objects.

In the statement, I apply Any() on the people objects’ FirstName property to determine if all objects in the collection have a LastName which contains the letter ‘s’.