IndexOf methods:
First, here we note that there are four IndexOf instance methods. The first two methods find the first indexes. They scan through the characters from the left to right. The second two find the last indexes, and they go from right to left.
IndexOf:This method finds the first index of the char argument. It returns -1 if the char was not found.
IndexOfAny:This method finds the first index of any of the char arguments. It returns -1 if none are found.
LastIndexOf:This finds the last index of the char argument. It returns -1 if the char was not found.
LastIndexOfAny:This finds the first index of any of the char arguments. It returns -1 if none are found.
Example:
string Path: C:\Documents and Settings\Jitendra\My Documents\Visual Studio 2008\Projects\WebApplication5\WebApplication5\
string k = stem.Web.HttpContext.Current.Request.PhysicalApplicationPath;
int o ;
k = k.Remove(k.LastIndexOf("\\"));
o = k.LastIndexOf("\\");
string appName1 = k.Substring(o+1);
Example:- string strFileName;
string strFile = strFileName.Substring(strFileName.LastIndexOf("\\")+1);
Thursday, January 13, 2011
Subscribe to:
Posts (Atom)