String::IndexOf Method (String)
Reports the zero-based index of the first occurrence of the specified string in this instance.
Namespace: System
Assembly: mscorlib (in mscorlib.dll)
Parameters
- value
- Type: System::String
The string to seek.
Return Value
Type: System::Int32The zero-based index position of value if that string is found, or -1 if it is not. If value is String::Empty, the return value is 0.
| Exception | Condition |
|---|---|
| ArgumentNullException | value is nullptr. |
Index numbering starts from zero.
This method performs a word (case-sensitive and culture-sensitive) search using the current culture. The search begins at the first character position of this instance and continues until the last character position.
Platform Notes
Silverlight for Windows Phone
Starting in Silverlight 4, the behavior of the String::IndexOf(String) method has changed. In Silverlight 4, it performs a case-sensitive and culture-sensitive comparison using the current culture to find the first occurrence of value. This conforms to the behavior of the String::IndexOf(String) method in the full .NET Framework. In Silverlight 2 and Silverlight 3, String::IndexOf(String) performs an ordinal comparison. If the common language runtime determines that a Silverlight-based application was compiled using either Silverlight 2 or Silverlight 3, it performs an ordinal comparison; otherwise, it performs a culture-sensitive comparison.
For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.