Showing posts with label program to reverse a string in c#. Show all posts
Showing posts with label program to reverse a string in c#. Show all posts

Monday, June 6, 2016

Write a program to reverse a string in C# .Net

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
 
namespace ConsoleApplication14
{
    class StringReverse
    {
        static void Main()
        {
 
            string S, rev = "";
            Console.Write("Enter A String ");
            S = Console.ReadLine();
 
            for (int i = S.Length - 1; i >= 0; i--)
            {
 
                rev = rev + S[i];
            }
 
            Console.WriteLine("Reverse  String  Is  {0}", rev);
            Console.ReadLine();
        }
    }

}

Output :