Exists2
Tests if any pair of corresponding elements of the collections satisfies the given predicate.
If any application returns true then the overall result is true and no further elements are tested. Otherwise, false is returned.
WARNING
This function causes
IEnumerable<T>evaluation.
| Parameters | Returns |
|---|---|
Func<T, T, bool> predicate IEnumerable<T> source1 IEnumerable<T> source2 |
bool |
Usage
Checking for the existence of a even and an odd number in any pair of the two collections
//IEnumerable<int> first = { 1, 3, 5, 7, 9, 9, 2 }
//IEnumerable<int> second = {1, 3, 1, 9, 2, 3, 5 }
bool result = first.Exists2(
second,
(value1, value2) => value1 % 2 == 0
&& value2 % 2 == 1);
//result = true when 2 && 5