Reverse a string using EX-OR operation in C#

Using exor operation also, we can reverse a string like below.

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

            char[] charArray = name.ToCharArray();
            int len = name.Length - 1;

            for (int i = 0; i < len; i++, len--)
            {
                charArray[i] ^= charArray[len];
                charArray[len] ^= charArray[i];
                charArray[i] ^= charArray[len];
            }

            string newName = new string(charArray);
            Console.WriteLine(newName);
        }
    }
}


Output:
Enter the string to reverse :
code

edoc