Posts

Showing posts with the label string reverse

string reverse

using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace stringreverse { class Program { static void Main(string[] args) { string first; int j=0; Console.WriteLine("Enter the first string"); first = Console.ReadLine(); char[] firstArr = first.ToCharArray(); char[] secondArr = first.ToCharArray(); for (int i = first.Length - 1; i >= 0; i--) { secondArr[j] = firstArr[i]; j++; } Console.WriteLine(secondArr); Console.ReadLine(); } } }