Searches the one-dimensional Array for a specific value, starting at the specified start index and ending at the element just prior to the specified end index (?).
[Visual Basic] Overloads Public Shared Function IndexOf( _ ByVal array As Array, _ ByVal value As Object, _ ByVal startIndex As Integer, _ ByVal endIndex As Integer _ ) As Integer [C#] public static int IndexOf( Array array, object value, int startIndex, int endIndex ); [C++] public: static int IndexOf( Array* array, Object* value, int startIndex, int endIndex ); [JScript] public static function IndexOf( array : Array, value : Object, startIndex : int, endIndex : int ) : int;
The index of the first occurrence of value in the range startIndex through endIndex-1 (?), or-1 if value does not occur in that range.
Exception Type | Condition |
---|---|
ArgumentNullException | array is a null reference (in Visual Basic Nothing). |
ArgumentOutOfRangeException | startIndex is outside the range of valid indices for array.
-or- endIndex is less than startIndex. -or- endIndex is greater than the last valid index of array plus 1 (?). |
The Array is searched forwards, starting at startIndex and ending at the element just prior to (?) endIndex, and the elements are compared to the specified value using the Equals method.
Array Class | Array Members | System Namespace | Array.IndexOf Overload List | LastIndexOf