Write a program in C# to reverse a string
Loading
Write a program in C# to reverse a string
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Amit MohantyPosted Jul 10, 2025, 5:10 AM
StephenKirkPosted Jan 6, 2026, 3:01 AM
How can I do this task?
Priya PrajapatiPosted Jan 4, 2026, 8:18 AM
Here is C# program for reverse a string without using reverse method.
Sandhiya PriyaPosted Jan 3, 2026, 4:08 AM
Here’s a simple C# program that reverses a string:
Explanation:
Console.ReadLine()? Reads user input.ToCharArray()? Converts the string into a character array.Array.Reverse()? Reverses the array in place.new string(charArray)? Creates a new string from the reversed array.Example Run:
Ajay BansodePosted Jul 13, 2025, 5:59 AM
Manual Reversal Logic:
using System;
class Program
{
static void Main()
{
Console.Write("Enter a string to reverse: ");
string input = Console.ReadLine();
string reversed = ReverseString(input);
Console.WriteLine("Reversed string: " + reversed);
}
static string ReverseString(string str)
{
string result = "";
for (int i = str.Length - 1; i >= 0; i--)
{
result += str[i]; // Append characters from end to start
}
return result;
}
}
Praveen KumarPosted Jul 10, 2025, 8:01 AM
C# Corner forums are here to help you learn and grow as a developer. Instead of asking for a complete solution like ‘Write a program to reverse a string,’ we encourage you to try writing some code yourself first. Share what you’ve attempted, and we’ll be happy to guide you from there!
Cynthia SathuragiriPosted Jul 10, 2025, 6:33 AM
We can use LINQ's Reverse() to reverse the characters. Here we can code a method in just a few lines
class Program
{
static void Main()
{
Console.Write("Enter a string: ");
string input = Console.ReadLine();
Console.WriteLine("Reversed string: " + new string(input.Reverse().ToArray()));
}
}