Monday, May 27, 2013

String Reversal (C#)

class Program()
{
static void Main()
{
string str = "this is a string";
char[] charArr = str.ToCharArray();
StringBuilder build = new StringBuilder();

for (int i = charArr.lenght-1; i >=0; i--)
{
build.Append(charArr[i]);
}
Console.WriteLine(build.ToString());
Console.ReadKey();
}
}

No comments: