Skip to content

Quantifiers

Context: Quantifiers (Any, All, Contains) check conditions on a sequence and return a bool.

int[] numbers = { 1, 2, 3 };
bool anyEven = numbers.Any(n => n % 2 == 0); // true
bool allPositive = numbers.All(n => n > 0); // true
bool containsTwo = numbers.Contains(2); // true

Validation: Use Any to check if a collection has items before processing.

Example: In EF Core, Any translates to EXISTS in SQL, which is efficient.