ForAll

Tests if all elements of the collection satisfy the given predicate.

If any application returns false then the overall result is false and no further elements are tested. Otherwise, true is returned.

WARNING

This function causes IEnumerable<T> evaluation.

Parameters

Returns

Func<T, bool> predicate

IEnumerable<T> source

bool

Usage

Verifying that all values in the collection are even numbers

//IEnumerable<int> source = { 2, 4, 6, 8, 10 }
bool result = source.ForAll(value => value % 2 == 0);

//result = true

Last updated