Exists
Tests if any element of the collection 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.
Parameters | Returns |
---|---|
Func<T, bool> predicate IEnumerable<T> source |
bool |
Usage
Checking if the collection contains an even number
//IEnumerable<int> source = { 1, 3, 5, 7, 8, 9, 11 }
bool result = source.Exists(value => value % 2 == 0);
//result = true