Reverse the String Array in C#

In this article I will explain that how to Reverse String in Array.
  • 5081

The receives a string parameter, which is the string in which you wish to reverse the order of the letters. The method is static because it doesn't store state. 

namespace demo_arraylist

{

    class Program

    {

        static void Main(string[] args)

        {

            //Program that uses Array to Revers String

            Console.WriteLine(StringHelper.RString("WELCOME"));

            Console.WriteLine(StringHelper.RString("computer"));

            Console.ReadKey();

        }

        //This is a method of Reverse string

        static class StringHelper

        {

            /// Receives string and returns the string with its letters reversed.

            public static string RString(string s)

            {

                char[] arr = s.ToCharArray();

                Array.Reverse(arr);

                return new string(arr);

            }

        }

    }

}

Output

reverse string.jpg

Ask Your Question 

Got a programming related question? You may want to post your question here

Programming Answers here

Categories

More Articles

© 2020 DotNetHeaven. All rights reserved.