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); // truebool allPositive = numbers.All(n => n > 0); // truebool containsTwo = numbers.Contains(2); // trueReal-world usage example
Section titled “Real-world usage example”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.