C# program to print given string in reverse order


Following program shows you how to print given string in reverse order.

using System;

class MainClass {
  public static void Main (string[] args) {
    Console.WriteLine("Please enter a string:");
    string input = Console.ReadLine();
    string output = "";
    int length = input.Length;
    for (int i = length; i > 0; i--)
    output = output + input[i - 1];
    Console.WriteLine("Reverse of given string is: " + output);
  }
}

Output:

Please enter a string:
 abcdefg
Reverse of given string is: gfedcba