Determines the position within this string of the first occurrence of the specified string.
[Visual Basic] Overloads Public Function IndexOf( _ ByVal value As String _ ) As Integer [C#] public int IndexOf( string value ); [C++] public: int IndexOf( String* value ); [JScript] public function IndexOf( value : String ) : int;
Value | Condition |
---|---|
The position | If the string is found. |
The position search began | If the string is the empty string. |
-1 | If the string is not found. |
Exception Type | Condition |
---|---|
ArgumentNullException | If the string is null. |
The IndexOf method searches for a specified string and returns the index. The search begins at the first character of this string. The search is case-sensitive, CultureInfo sensitive, and the default locale is used. This method returns the CurrentCulture information.
The value parameter returns the position from where search commenced if value is the empty string (see Empty).
String Class | String Members | System Namespace | String.IndexOf Overload List | Int32