To reverse a string, use the Array.Reverse() method.
Set the string you want to reverse −
string str = "Amit";
In the above method, we have converted the string into character array −
char[] ch = str.ToCharArray();
Then the Reverse() method is used.
Array.Reverse(ch);
Example
using System;
namespace Demo {
class Program {
static void Main(string[] args) {
string str = "Amit";
char[] ch = str.ToCharArray();
Array.Reverse(ch);
foreach(var items in ch) {
Console.WriteLine(items);
}
Console.ReadLine();
}
}
}