FindIndex
Returns the index of the first element in the collection that satisfies the given predicate
.
Parameters
Returns
Func<T, bool> predicate
IEnumerable<T> source
int
Exceptions
Type
When
InvalidOperationException
The predicate function returns false for all elements.
Usage
Find the index ofthe first even number
//IEnumerable<int> source = { 1, 3, 5, 7, 8, 9, 10 }
bool result = source.FindIndex(value => value % 2 == 0);
//result = 4
Last updated
Was this helpful?