Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Selected Reading
How to reverse a String using C#?
To reverse a string, use the Array.Reverse() method.
Set the string you want to reverse −
string str = "Amit";
In the above method, we have converted the string into character array −
char[] ch = str.ToCharArray();
Then the Reverse() method is used.
Array.Reverse(ch);
Example
using System;
namespace Demo {
class Program {
static void Main(string[] args) {
string str = "Amit";
char[] ch = str.ToCharArray();
Array.Reverse(ch);
foreach(var items in ch) {
Console.WriteLine(items);
}
Console.ReadLine();
}
}
} Advertisements
