LINQ All Operator - Sequence - Test All Elements Satisfy Condition

By Indranil Chatterjee
ODBC Drivers for QuickBooks, Salesforce, SAP, MSCRM, SharePoint … Free Trial!

The LINQ All operator allows to test if all elements of a sequence satisfy a condition.

The following code sample demonstrates how:

int[] numbers = {2, 4, 6, 8};
bool allEven = numbers.All(n => n % 2 == 0); // this returns true for the given array but false for {2,3,6,8}

LINQ All Operator - Sequence - Test All Elements Satisfy Condition  (422 Views)