ExtensionMethod.NET Home of 880 C#, Visual Basic, F# and Javascript extension methods

Reverse

Reverse a string

Source

static class Helpers
{
   public static string Reverse(this string s)
   {
      char[] c = s.ToCharArray();
      Array.Reverse(c);
      return new string(c);
   }
}

Example

string s = "Test";
string r = s.Reverse(); // "tseT"

Author: unknown

Submitted on: 21 aug. 2007

Language: C#

Type: System.String

Views: 5341