16 December 2013

Reverse a String Without Using Function in C#



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

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            string str, revstr="";
            int l;
            Console.WriteLine("enter astring:");
            str = Console.ReadLine();
            l = str.Length-1;
            while (l >= 0)
            {
                revstr = revstr + str[l];
                l--;
            }
            Console.WriteLine("Reverse String is :: {0}" ,revstr);
            Console.ReadLine();
        }
    }
}



output

No comments:

Post a Comment