Wednesday, February 1, 2012

Reverse String in C#.Net

 Reverse String in C#.Net

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ReverseStringBySaalaMaiToSoftwareEngineerBanGya
{
    class Program
    {
        static void Main(string[] args)
        {
            ReverseClass obj = new ReverseClass();
            string str = obj.Reverse("MANISH AGRAHARI");
            Console.WriteLine(str);
            Console.ReadLine();
           
        }

        class ReverseClass
        {
            public string Reverse(string input)
            {
                string output = string.Empty;
                int len = input.Length;
                int index = len - 1;

                for (int i = index; i >= 0; i--)
                {
                    output = output + input[i];
                }

                return output;
            }
        }
       
    }
}


0 comments: