Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
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
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
Advertisements