LINQ Any Operator - Test if any element of a sequence satisfies a condition

By Indranil Chatterjee
Access over 40 UI widgets with everything from interactive menus to rich charts.

The LINQ Any operator allows to test if any element of a sequence satisfies a condition.

The following code sample demonstrates how:

int[] numbers = {3,5,6,9};
bool anyEven = numbers.Any(n => n % 2 == 0); // this returns true for the given array but false for {3,5,7,9}

LINQ Any Operator - Test if any element of a sequence satisfies a condition  (277 Views)