Array.FindIndex<(Of <(T>)>) Method (array<T>[]()[], Predicate<(Of <(T>)>))

[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]

Searches for an element that matches the conditions defined by the specified predicate, and returns the zero-based index of the first occurrence within the entire Array.

Namespace:  System
Assembly:  mscorlib (in mscorlib.dll)

Syntax

Public Shared Function FindIndex(Of T) ( _
    array As T(), _
    match As Predicate(Of T) _
) As Integer
public static int FindIndex<T>(
    T[] array,
    Predicate<T> match
)

Type Parameters

  • T
    The type of the elements of the array.

Parameters

  • array
    Type: array<T>[]()[]
    The one-dimensional, zero-based Array to search.

Return Value

Type: System..::.Int32
The zero-based index of the first occurrence of an element that matches the conditions defined by match, if found; otherwise, –1.

Exceptions

Exception Condition
ArgumentNullException

array is nullNothingnullptra null reference (Nothing in Visual Basic).

-or-

match is nullNothingnullptra null reference (Nothing in Visual Basic).

Remarks

The Array is searched forward starting at the first element and ending at the last element.

The Predicate<(Of <(T>)>) is a delegate to a method that returns true if the object passed to it matches the conditions defined in the delegate. The elements of array are individually passed to the Predicate<(Of <(T>)>).

This method is an O(n) operation, where n is the Length of array.

Version Information

Windows Phone OS

Supported in: 8.1, 8.0

See Also

Reference

Array Class

FindIndex Overload

System Namespace

BinarySearch

IndexOf

LastIndexOf

Predicate<(Of <(T>)>)