Click or drag to resize
StringIndexOf Method (String, StringComparison)
Reports the zero-based index of the first occurrence of the specified string in the current String object. A parameter specifies the type of search to use for the specified string.

Namespace: System
Assembly: mscorlib (in mscorlib.dll) Version: 4.0.0.0
Syntax
C#
public int IndexOf(
	string value,
	StringComparison comparisonType
)

Parameters

value
Type: SystemString
The string to seek.
comparisonType
Type: SystemStringComparison
One of the enumeration values that specifies the rules for the search.

Return Value

Type: Int32
The index position of the value parameter if that string is found, or -1 if it is not. If value is Empty, the return value is 0.
Exceptions
ExceptionCondition
ArgumentNullExceptionvalue is null.
ArgumentExceptioncomparisonType is not a valid StringComparison value.
See Also