Returns the index of the first occurrence of the character in the current instance.
[Visual Basic] Overloads Public Function IndexOf( _ ByVal value As Char, _ ByVal startIndex As Integer, _ ByVal endIndex As Integer _ ) As Integer [C#] public int IndexOf( char value, int startIndex, int endIndex ); [C++] public: int IndexOf( __wchar_t value, int startIndex, int endIndex ); [JScript] public function IndexOf( value : Char, startIndex : int, endIndex : int ) : int;
Value | Condition |
---|---|
The index in the string | If value is found. |
-1 | If value is not found. |
Exception Type | Condition |
---|---|
ArgumentOutOfRangeException | If either index is less than zero or greater than the length of the string. |
ArgumentOutOfRangeException | If the ending index is less than the start index. |
The IndexOf method performs a search for the first occurance of the character and marks it as an index. The search begins at the specified position and continues until the end of the string (startIndex and runs to endIndex-1 (startIndex, endIndex)). The character at the position at the end of the index is not included in the search. The search is case-sensitive and begins the indexing at zero.
String Class | String Members | System Namespace | String.IndexOf Overload List | Int32