Reverse a string in C#

CsharpProgrammingServer Side Programming

To reverse a string, use the Array. Reverse() method.

We have set a method and passed the string value as “Henry” −

public static string ReverseFunc(string str) {
   char[] ch = str.ToCharArray();
   return new string(ch);

In the above method, we have converted the string into character array −

char[] ch = str.ToCharArray();

Then the Reverse() method is used −

Updated on 21-Jun-2020 15:54:35