Method to reverse the string

The simple way to reverse a string is as follows..


public String Reverse(String strParam)
{
if (strParam.Length == 1)
return strParam;
else
return Reverse(strParam.Substring(1)) + strParam.Substring(0, 1);
}


Hope this post is helpful for you.


Comments

Author: Nathan11 Jul 2009 Member Level: Gold   Points : 0

Good work chenthil
Keep it up

Author: Dotnet Developer-201522 Jul 2015 Member Level: Gold   Points : 3

Hi
Centhil

You can try this code also Reverse String

How to Call the method


string ff= Reverse("Welcome");


How to Return the Method


public string Reverse(string Getstr)
{
string conc = "";
for (int i = Getstr.Length-1; i >=0; i--)
{
conc = conc + Getstr[i];
}
return conc;
}



  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:
    Email: