This post shows you how to reverse a string without using Reverse function in C#. You may ask me ,why should I have to know when there is already a build-In Reverse function?. But, this kind of questions asked numbers of times in Interviews. It is always good to be prepared.
Here is the code, Copy and paste and see the result in Visual Studio:
using System; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { string text = "Spiderman!"; string reverse = string.Empty; foreach (char ch in text) { reverse = ch + reverse; } Console.Write(reverse); Console.ReadKey(); } } }
I hope this post will help you to get a job 🙂
can you post reverse string without using any methods too