C# Program to display a string in reverse alphabetic order


Set a string array and convert it to character array −

string str = "Amit";
char[] arr = str.ToCharArray();

Now, use the Reverse method to display the above string in reverse alphabetic order −

Array.Reverse(arr);

Here is the complete code −

Example

 Live Demo

using System;
using System.Linq;
using System.IO;
class Program {
   static void Main() {
      string str = "Amit";
      char[] arr = str.ToCharArray();
      Console.WriteLine("Original String: "+str);
      // Reverse
      Array.Reverse(arr);
      Console.WriteLine("Reversed String: "+new string(arr));
   }
}

Output

Original String: Amit
Reversed String: timA

Updated on: 22-Jun-2020

579 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements