reverse string using c#

reverse string using c#
using System;

namespace ajayvishu
{
    public class Program
    {
         public static string Reverse(string x)
        {
            string result = "";
            for (int i = x.Length - 1; i >= 0; i--)
                result += x[i];
            return result;
        }

        public static void Main(string[] args)
        {
            var s=Reverse("hello i am ajay is here");
            Console.WriteLine(s);
        }
    }
}

OR:

var a = "hello i am ajay is here";
char[] arr = a.ToCharArray();
Array.Reverse(arr);

Post a Comment

0 Comments