Reverse a string using String builder in C#

We can use string builders to reverse a string by adding/appending the characters in reverse.

using System;
using System.Text;

namespace forgetCode
{
    class Program
    {
        public static void Main(string[] args)
        {
            Console.WriteLine("Enter the string to reverse :");
            string name = Console.ReadLine();

            StringBuilder builder = new StringBuilder();
            for (int i = name.Length - 1; i >= 0; i--)
            {
                builder.Append(name[i]);
            }
            string newName =builder.ToString();

            Console.WriteLine(newName);

        }
    }
}


Output:

Enter the string to reverse :
forget code

edoc tegrof