ArrayExtensions.IndexOf<T>

Extension Method in ArrayExtensions

Declaration

public static int IndexOf<T>(this T[] array, T element)
    where T : IEquatable<T>

Description

Returns the index of the given element in the array.

Type Parameters

TThe type of the array.

Parameters

arrayThe array to search in.
elementThe element to search for.

Returns

intThe index of the element in the array.

Overload

Declaration

public static int IndexOf<T>(this T[] array, Predicate<T> predicate)

Description

Returns the index of the first element in the array that satisfies the predicate.

Type Parameters

TThe type of the array.

Parameters

arrayThe array to search in.
predicateThe predicate to use.

Returns

intThe index of the element, or -1 if not found.