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

Please see my other LINQ articles.

Use All() to test an entire collection.

In this article I’ll demonstrate how to use All() to determine if the entire collection matches a search predicate.

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

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