Share via


Array.IndexOf Method (Array, Object)

Searches an entire one-dimensional array for a specified object and returns the index number of the first occurrence of that object (if any) in the array.

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

Syntax

 public static int IndexOf (
         Array array,
         Object value
)

Parameters

  • array
    The one-dimensional array you want to search.
  • value
    The object you want to search for in the one-dimensional array.

Return Value

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

Remarks

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

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 .NET Micro Framework version 2.0, 2.5

See Also

Reference

Array Class
Array Members
System Namespace