Partager via


Array.IndexOf Method (Array, Object, Int32)

Searches for a specified object in a defined range (search range) within a one-dimensional array, starting at a specified index number and ending at the last object in the entire array. Returns the index number of the first occurrence of that object (if any) in the search range.

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

Syntax

public static int IndexOf (
         Array array,
         Object value,
         int startIndex
)

Parameters

  • array
    The one-dimensional array that contains the search range.
  • value
    The object you want to look for in the search range.
  • startIndex
    The starting index number in the search range.

Return Value

The index number of the first occurrence of the specified object (if any) in the search range. If the object is not found in the search range, this method returns -1.

Remarks

The search range in the one-dimensional array is searched forward, starting at the first object in the range and ending at the last object in the range.

Use the Object.Equals method to compare the specified object with the objects in the search range. If the specified object is of a nonintrinsic (programmer-defined) type, use the Equals implementation for that type.

Version Information

Available in the .NET Micro Framework versions 2.0, 2.5, 3.0, 4.0, 4.1, and 4.2.

See Also

Reference

Array Class
Array Members
System Namespace