Click or drag to resize

XEnumerableIndexOfTSource Method (IEnumerableTSource, FuncTSource, Boolean)

Returns the position of the first element of source that verifies the specified predicate, or -1 if it is not found.

Namespace:  Linq.Extras
Assembly:  Linq.Extras (in Linq.Extras.dll) Version: 5.0.0+96a4f4bfed64095342c5df107c1fe1fb95603ee5
Syntax
public static int IndexOf<TSource>(
	this IEnumerable<TSource> source,
	Func<TSource, bool> predicate
)

Parameters

source
Type: System.Collections.GenericIEnumerableTSource
The sequence to search for a matching element.
predicate
Type: SystemFuncTSource, Boolean
The predicate that is tested against each element.

Type Parameters

TSource
The type of the elements of source.

Return Value

Type: Int32
The zero-based index of the first element that verifies the predicate, or -1 if no element verifies the predicate.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type IEnumerableTSource. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).
See Also