We need to write a simple C# code to demonstrate a reversing the given input string at runtime. Below is the code snippet to achive this.
class Program
{
internal static void ReverseString(string str)
{
char[] charArray = str.ToCharArray();
for (int i = 0, j = str.Length - 1; i < j; i++, j--)
{
charArray[i] = str[j];
charArray[j] = str[i];
}
string reversedstring = new string(charArray);
Console.WriteLine(reversedstring);
}
static void Main(string[] args)
{
ReverseString(args[0]);
Console.ReadKey();
}
}