+ 1
How do I turn a string backwards using c# ?
Is it possible to turn a string backwards ?.Please if there is can you show me.
6 ответов
+ 5
Here is another approach using built in method Array.Reverse
https://code.sololearn.com/c3FGepbX71qC/#cs
+ 4
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
+ 4
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.
+ 3
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
+ 3
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);
}
+ 2
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.