DotNet Mirror
  DNM facebook   DNM Google+   DNM Twitter   

Reverse string using Array.Reverse function in C#

By Ashok Nalam on 16 Sep 2013 | Category: C# | Tagged: string .NET array 
In this snippet we will a simple program which reverse a string using Array.Reverse built in function using C#.NET.
  Discuss Add Comment   |  
Add rating Rate this resource   

In this snippet we will a simple program which reverse a string using Array.Reverse built in function using C#.NET. 

Array.Reverse Method - Reverses the order of the elements in a one-dimensional Array or in a portion of the Array.

    class ReverseString
    {
        static void Main()
        {
            Console.WriteLine(ReverseStr("DotNetMirror"));
            Console.WriteLine(ReverseStr(".NET Mirror"));      
            Console.ReadLine();
        }
        public static string ReverseStr(string s)
        {
            char[] arr = s.ToCharArray();
            Array.Reverse(arr);
            return new string(arr);           
        }

    }

Output:

rorriMteNtoD

rorriM TEN.

  Discuss Add Comment    
Add rating Rate this resource   
About the Contributor
Member Since : 10 Dec 2012
Member Points (Level) : 9226  (Professional)
Location : INDIA
Home Page : http://dotnetmirror.com
About : I am admin of this site.
Rate this resource
 
Add your Comment
Name Email WebSite
Captcha Refresh


Comments (0)
No comments found, click here to add comment.
 
cheap jordans|wholesale air max|wholesale jordans|wholesale jewelry|wholesale jerseys