Quantifier operations return a Boolean value that indicates whether some or all of the elements in a sequence satisfy a condition.
All
Determines whether all the elements in a sequence satisfy a condition.
Method Syntax
// All
var numbers = new int[] { 1, 2, 3, 4, 5 };
bool areLessThan10 = numbers.All(n => n < 10);
// areLessThan10 = true
Query Syntax
// Not applicable.
Any
Determines whether any elements in a sequence satisfy a condition.
Method Syntax
// Any
var numbers = new int[] { 1, 2, 3, 4, 5 };
bool anyOneIsEven = numbers.Any(n => n % 2 == 0);
// anyOneIsEven = true
Query Syntax
// Not applicable.
Contains
Determines whether a sequence contains a specified element.
Method Syntax
// Contains
var numbers = new int[] { 1, 2, 3, 4, 5 };
bool appears = numbers.Contains(10);
// appears = false
Query Syntax
// Not applicable.