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


C# Examples » Data Structure » Array Reverse »

 

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









    
using  System;

class  MainClass
{

    public  static  void  Main()
    {
        string[]  stringArray  =  {"t",  "i",  "a",  "test",  "abc123",  "abc345"};
        Array.Sort(stringArray);
        
        Array.Reverse(stringArray);
        Console.WriteLine("Reversed  stringArray:");
        for  (int  i  =  0;  i  <  stringArray.Length;  i++)
        {
            Console.WriteLine("stringArray["  +  i  +  "]  =  "  +  stringArray[i]);
        }
    }

}
    
   
  
   



Output

Reversed stringArray:
stringArray[0] = test
stringArray[1] = t
stringArray[2] = i
stringArray[3] = abc345
stringArray[4] = abc123
stringArray[5] = a


HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo Data Structure
» Array Reverse