Quantifiers
LINQ offers two interesting extension methods for sequences, Any and All. Any allows checking if at least one item in the sequence satisfies the specified condition. For example, the following code checks if at least one product name contains the letters “of”:
Dim result = products.Any(Function(p) p.ProductName.Contains("of"))
The method receives a lambda as an argument that specifies the condition and returns True if the condition is matched. All instead allows checking if all members in a sequence match the specified condition. For example, the following code checks if all products are discontinued:
Dim result = products.All(Function(p) p.Discontinued = True)
Same as above, the lambda argument specifies the condition to be matched. ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access