string class : IndexOf(string,int) method
Description
Gets the index of the first occurrence of the specified string in the invoker string.
It searches from a specified character position toward the end.
Syntax
stringInstance.IndexOf(string searchString, int startPosition)
Arguments
| Class | Name | Description |
| string | searchString | A search string. |
| int | startPosition | A start position of searching. |
Return value
| Class | Description |
| int | Index of the found position. |
Sample code
| 1: | string str = "abcba"; |
| 2: | int index = str.IndexOf("b",2); // The result (index) is 3. |
Notes
It's a wrapper of the System.String.IndexOf(String,Int32).
However, it has supported to the surrogate characters of UTF-8. In other words, It returns an index as number of characters. Please be aware it is not number of bytes.
The index is zero-based.
Returns -1 if it is not found.


