To reverse a string, use the Array.Reverse() method.
Set the string to be reversed −
string str = "Amit";
In the above method, we convert the string into a character array −
char[] ch = str.ToCharArray();
and then use the Reverse() method. The Chinese translation of
Array.Reverse(ch);
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(); } } }
The above is the detailed content of How to reverse a string using C#?. For more information, please follow other related articles on the PHP Chinese website!