Why can't this code turn this string backwards ? | Sololearn: Learn to code for FREE!


Why can't this code turn this string backwards ?

I tried to turn a word backwards using this code, but it doesn't turn it backwards. The code just displays the word I wrote. using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace SoloLearn { class Program { static void Main(string[] args) { string Name = "joseph"; char[] reverse = Name.ToCharArray(); Array.Reverse(reverse); string Reversedname = new string(Name); Console.WriteLine(Reversedname); } } }

4/19/2020 1:36:27 PM

Joseph Oritseweyinmi

1 Answer

New Answer


Joseph Oritseweyinmi You are printing original String. Convert reversed character array to String and print that. string Reversedname = new string(reverse);