Saturday, 26 September 2015

How to Reverse a String in C# .Net

How to Reverse a String in C# .Net 

Step :-1

  1. Open Microsoft Visual Studio.
  2. Then go to to "File" -> "New" -> "Project..." then select Visual C# -> Windows -> Console application.









Step :-2

Then Write the Code For The Reverse a String.
----------------------------------------------------------------------------------------------------------------------
using System;

namespace ReverseAString
{
    class Program
    {
        static void Main(string[] args)
        {
            string Str, Revstr = ""
            int Length;

            Console.Write("Enter A String : ");
            Str = Console.ReadLine();

            Length = Str.Length - 1;
            
            while (Length >= 0)
            {

                Revstr = Revstr + Str[Length];
                Length--;

            }

            Console.WriteLine("Reverse  String  Is  {0}", Revstr);

            Console.ReadLine();

        }
    }
}
--------------------------------------------------------------------------------------------------------

Source-Code Image


Step :-3

Run This Application...
Output :-      Enter A String :- DOTNET TRICKS BY VICKY RAJ
                     Reverse String Is :- JAR YKCIV YB SKCIRT TENTOD



RESULT:-



















Thank You For Visit Here !!










No comments:

Post a Comment

Factorial of a Number

Recently Viewed