Search This Blog

Monday, October 8, 2012

IndexOf c#

C# > String > IndexOf

Reports the zero-based index of the first occurrence of the specified string in another string.

Index numbering starts from zero.

The zero-based index position of value if that string is found, or -1 if it is not.

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.

Example:

string ast_name = valuePath;
int poz = ast_name.IndexOf("http");
if (poz >-1) // found "http"
   ast_name = ast_name.Substring(poz,ast_name.Length-poz);