Mono Class Library: System.String Overview | Members

System.String.IndexOf Method

Returns the index of the first occurrence of a specified string in the current instance, with the search over the specified range starting at the provided index.

public int IndexOf (string value, int startIndex, int count)

Parameters

value
The string for which to search
startIndex
A int containing the index of the current instance from which to start searching.
count
A int containing the number of consecutive elements of the current instance to be searched starting at startIndex.

Returns

A int that indicates the result of the search for value in the current instance as follows:

Return ValueDescription
A zero-based number equal to the index of the start of the first substring in the current instance that is equal to value .value was found starting at the index returned.
-1value was not found.

Exceptions

TypeReason
ArgumentNullExceptionvalue is a null reference.
ArgumentOutOfRangeException

startIndex or count is negative

-or-

startIndex + count is greater than the length of the current instance.

Remarks

The search begins at startIndex and continues until startIndex + count - 1 is reached. The character at startIndex + count is not included in the search.

This method is case-sensitive.

Requirements

Namespace: System
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0