How to reverse string in C#
Kirtesh Shah
Method 1: Using ToCharArray() and Array.Reverse()
string str = “hello”;char[] charArray = str.ToCharArray();Array.Reverse(charArray);string reversed = new string(charArray);Console.WriteLine(reversed); // Output: “olleh”
Method 2: Using LINQusing System;using System.Linq;
string str = “world”;string reversed = new string(str.Reverse().ToArray());Console.WriteLine(reversed); // Output: “dlrow”