Use the Reverse() method to reverse the elements in charArray : Array Reverse : Data Structure C# Examples


C# Examples » Data Structure » Array Reverse »

 

Use the Reverse() method to reverse the elements in charArray









    
using  System;

class  MainClass
{

    public  static  void  Main()
    {
        char[]  charArray  =  {'w',  'e',  'l',  'c',  'o',  'm',  'e'};
        Array.Sort(charArray);    //  sort  the  elements            

        Array.Reverse(charArray);
        Console.WriteLine("Reversed  charArray:");
        for  (int  i  =  0;  i  <  charArray.Length;  i++)
        {
            Console.WriteLine("charArray["  +  i  +  "]  =  "  +  charArray[i]);
        }
    }

}
    
   
  
   



Output

Reversed charArray:
charArray[0] = w
charArray[1] = o
charArray[2] = m
charArray[3] = l
charArray[4] = e
charArray[5] = e
charArray[6] = c


HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo Data Structure
» Array Reverse