ForAll2
Tests if all corresponding elements of the collection satisfy the given predicate
pairwise.
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, T2, bool> predicate
IEnumerable<T> source
IEnumerable<T2> source2
bool
Usage
Verifying that all values in both collections are even numbers
Creating an true result even when one of the collections contains an odd number
It is necessary to be careful, different sized collections can create situations like this one:
The result was true
because of the loop runs only until the smallest collection length, therefore, the last element of source2
never was checked.
Last updated
Was this helpful?