+ 1
How to reverse a string In C#
How to reverse the word that string contain!
3 Answers
+ 1
There are several ways - in java you can turn your String into a set of characters
e.g.
"mystring" = 'm' + 'y' + 's' + 't' + 'r' + 'i' + 'n' + 'g'
Then you use a simple for loop and and reverse it
for (int i = myString.Length; i = 0; i--) {
reversedString += mystring.charAt( i);
}
This is just pseudocode so you'll have to check the proper implementation - try looking for charAt equivalent for C#
There's other reverse methods already implemented in the language
+ 3
Give it a try and post your logic atleast.
You don't learn anything if the answers come with a spoon.
- 1
In Python, one can reverse a string by this method -
(Assume the string to be x)
x = x[::-1]
This happens because the argument after 2 colons refers to the step and -1 will do it reverse.