C# String IndexOf(String)
Description
String IndexOf(String)
reports the zero-based index
of the first occurrence of the specified string in this instance.
Syntax
String.IndexOf(String)
has the following syntax.
public int IndexOf(
string value
)
Parameters
String.IndexOf(String)
has the following parameters.
value
- The string to seek.
Returns
String.IndexOf(String)
method returns The 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.
Example
The following code shows how to use
String.IndexOf(String)
method.
/*from ww w .ja va 2s. c o m*/
using System;
public class Example
{
public static void Main()
{
string s1 = "ani\u00ADmal";
string s2 = "animal";
Console.WriteLine(s1.IndexOf("\u00AD"));
}
}
The code above generates the following result.