namespace DemoExample
{
    class Program: ReverseString
    {
        static void Main(string[] args)
{
ReverseString objReverse = new ReverseString();
            //reverse a string with Inbuilt function in C#
            // With Inbuilt Method Array.Reverse Method
            string resultReverseAStringWith = objReverse.ReverseAStringWithReverseMethod("ANILKUMARSINGH");//Output -"HGNISRAMUKLINA"
            //reverse a string without Inbuilt function in C#
            //Using While Loop
string resultReverseAStringWithout = objReverse.ReverseAStringWithoutReverseMethod("ANILKUMARSINGH");//Output -"HGNISRAMUKLINA"
        }
      
    }
    class ReverseString
    {
        // Reverse a string with Inbuilt function in C#
        // With Inbuilt Method Array.Reverse Method
        public string ReverseAStringWithReverseMethod(string str)
        {
char[] chars = str.ToCharArray();
            Array.Reverse(chars);
return new string(chars);
        }
        //Reverse a string without Inbuilt function in C#
        //Using While Loop
        public string ReverseAStringWithoutReverseMethod(string str)
        {
            string reverseStr = string.Empty;
int length= str.Length - 1;
            while (length >=0)
            {
                reverseStr = reverseStr + str[length];
                length--;
}
return reverseStr;
        }
    }
}
