How to reverse a string in C#

Shared by: unknown user

csharp

1
using System;
2
class ReverseString
3
{
4
    static void Main(string[] args)
5
    {
6
        string str = "Educative";
7
        char[] stringArray = str.ToCharArray();
8
        Array.Reverse(stringArray);
9
        string reversedStr = new string(stringArray);
10
        Console.Write($"Actual String is : {str} \n");
11
        Console.Write($"Reversed String is : {reversedStr} ");
12
    }
13
}