we can reverse a string in so many methods..
method 1
string str="Suresh Varma";
char[] rev=str.ToChatArray(str);
Array.Reverse(rev);
Response.Write(new string(rev));
out put...> amraV hseruS
method 2:
string str="9000588819";
string rev="";
for ( int i=0;i < str.length;i++)
{
rev+=str.SubString(str.length-i,1);
}
response.write(rev);
o/p 9188850009
method 3:(works only in VB.net)
Import Microsoft.VisualBasic
dim str as new string=strReverse("varma")
response.Write(str)
o/p amrav
Subscribe to:
Post Comments (Atom)

No comments:
Post a Comment