+ 1

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); } } }

19th Apr 2020, 1:36 PM
Joseph Oritseweyinmi
Joseph Oritseweyinmi - avatar
1 Odpowiedź
+ 1
Joseph Oritseweyinmi You are printing original String. Convert reversed character array to String and print that. string Reversedname = new string(reverse);
19th Apr 2020, 1:45 PM
A͢J
A͢J - avatar