using System;
static class StringHelper
{
/// <summary>
/// Receives string and returns the string with its letters reversed.
/// </summary>
public static string ReverseString(string s)
{
char[] arr = s.ToCharArray();
Array.Reverse(arr);
return new string(arr);
}
}
class Program
{
static void Main()
{
Console.WriteLine(StringHelper.ReverseString("framework"));
Console.WriteLine(StringHelper.ReverseString("samuel"));
Console.WriteLine(StringHelper.ReverseString("example string"));
}
}
Wednesday, 18 July 2012
Example program that reverses strings [C#]
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment