3/16/2020 5:46:43 AM
Joseph Oritseweyinmi6 Answers
New AnswerHere is another approach using built in method Array.Reverse https://code.sololearn.com/c3FGepbX71qC/#cs
Just like every programming language C# has a lot of ways to reverse a string. Here's a hint, Take a string, use .ToCharArray() method of string and convert string to character array then use Array.Reverse() to reverse the array and then again convert it to string. cheers
0_O-[Mägár_Sám_Äkà_Nüllpøïntêr_Èxëcéptïön]~~ Stack by default push element from backward so definetly it will give in reverse order.
Yes we can do like this: String str = "Anant"; String newstr = ""; for(int I = (str.Length - 1); I >=0; I--) { newstr = newstr + str[I]; } https://code.sololearn.com/cMaamAxIcNNT/?ref=app
Joseph Oritseweyinmi you can use Stack if you want to do differently Stack myStack = new Stack(); myStack.Push(1); myStack.Push(2); myStack.Push(3); myStack.Push(4); foreach(var item in myStack){ Console.WriteLine(item); }
Use arrayLength-1 as the starting point and iterate till index 0 to get the result. A simple for loop will do the job. Show the community your attempt so that it becomes easy to make corrections.
Sololearn Inc.
535 Mission Street, Suite 1591Send us a message