Let say you have a string and you want its first or last character like first 2 or last 4 how could you do that?
here is sample for that
string mystring = "122014";
mystring = mystring.Substring(mystring.Length - 4);
Response.Write(mystring.ToString());
//output:2014
mystring = "122014";
string sub = mystring.Remove(mystring.Length - 4);
Response.Write("<br>");
Response.Write(sub.ToString());
//output: 12
here is sample for that
string mystring = "122014";
mystring = mystring.Substring(mystring.Length - 4);
Response.Write(mystring.ToString());
//output:2014
mystring = "122014";
string sub = mystring.Remove(mystring.Length - 4);
Response.Write("<br>");
Response.Write(sub.ToString());
//output: 12
No comments:
Post a Comment