Compartir a través de


Array.IndexOf Method (Array, Object, Int32, Int32)

Searches for a specified object in a defined range (search range) within a one-dimensional array, starting at the specified index number and searching through a specified number of objects. 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,
         int count
)

Parameters

  • array
    The one-dimensional array that contains the search range.
  • value
    The index number of the object you want to look for in the search range.
  • startIndex
    The starting index number in the search range.
  • count
    The number of objects 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 range, the return value is -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