application which writes a string in reverse
Hi
I'm learning to program, using this book (Beginning Microsoft Visual C# 2008 ISBN: 978-0-470-19135-4 ). Chapter 5, exercise 5 requires an application with which a string can be accepted from the user and it can output a string with characters in reverse. I'm using Visual C# 2010 Express, for an IDE.
I've looked up for the solution, which goes like this :
Console.WriteLine("Enter a string:");
string myString = Console.ReadLine();
string reversedString = "";
for (int index = myString.Length - 1; index >= 0; index--)
{
reversedString += myString[index];
}
Console.WriteLine("Reversed: {0}", reversedString);
When I run this, I can't see the end because it just flashes out.
I don't know what is wrong.
|