Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

Array.System.Collections.IList.IndexOf Method

Searches for the specified object and returns the index of the first occurrence within the current one-dimensional instance.

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

'Declaration
Private Function System.Collections.IList.IndexOf ( _
	value As Object _
) As Integer Implements IList.IndexOf
'Usage
Dim instance As Array
Dim value As Object
Dim returnValue As Integer

returnValue = CType(instance, IList).IndexOf(value)
J# supports the use of explicit interface implementations, but not the declaration of new ones.
JScript supports the use of explicit interface implementations, but not the declarations of new ones.

Parameters

value

The object to locate in the current Array.

Return Value

The index of the first occurrence of value within the entire Array, if found; otherwise, the lower bound of the Array minus 1.
Exception typeCondition

RankException

The current Array is multidimensional.

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

The elements are compared to the specified value using the Object.Equals method. If the element type is a nonintrinsic (user-defined) type, the Equals implementation of that type is used.

Since most arrays will have a lower bound of zero, this method would generally return –1 when value is not found. In the rare case that the lower bound of the array is equal to Int32.MinValue and value is not found, this method returns Int32.MaxValue, which is System.Int32.MinValue - 1.

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

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 2.0, 1.0
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.