I know this is a simple question, but I thought I'd give it a try.
So say I have a TextBox named "toReverse". If I wanted to reverse all the text in that TextBox, how would I go about doing that?
Also, I can't use VB.NET in it, even though it has a one-line way of doing it.
You can pass it to Array of char and reverse it :)
There are several ways you could go about doing this if you don't want to use the built-in facilities. For example, you could create an array, reverse the array (with an explicit loop rather than
Array.Reverse
), and then create a new string from the array:Another way is to use a stack. Push the individual characters on the stack, then pop them off to populate a
StringBuilder
:Another way would be to walk through the string backwards, populating a
StringBuilder
:And of course there are many variations to the above.
Hope this helps