This is a C# Program to reverse a string without using reverse function.
This C# Program Reverses a String without using Reverse function.
Here the string is reversed by changing the postion of charters from right to left one by one.
Here is source code of the C# Program to Reverse a String without using Reverse function. The C# program is successfully compiled and executed with Microsoft Visual Studio. The program output is also shown below.
/* * C# Program to Reverse a String without using Reverse function */ using System; class Program { static void Main(string[] args) { string Str, reversestring = ""; int Length; Console.Write("Enter A String : "); Str = Console.ReadLine(); Length = Str.Length - 1; while (Length >= 0) { reversestring = reversestring + Str[Length]; Length--; } Console.WriteLine("Reverse String Is {0}", reversestring); Console.ReadLine(); } }
In this C# program, we are reading a string using ‘str’ variable. Using while loop the string is reversed by changing the position of characters from right to left one by one. The iteration of the loop will continue till the condition becomes false.
Enter a String : sanfoundry Reverse String is : yrdnuofnas
Sanfoundry Global Education & Learning Series – 1000 C# Programs.
- Get Free Certificate of Merit in C# Programming
- Participate in C# Programming Certification Contest
- Become a Top Ranker in C# Programming
- Take C# Programming Tests
- Chapterwise Practice Tests: Chapter 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
- Chapterwise Mock Tests: Chapter 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
- Apply for Computer Science Internship
- Buy MCA Books
- Apply for C# Internship
- Practice Computer Science MCQs
- Buy C# Books