27 02 2013
Implementation of a string reverse Extension Method
This is a follow-up of Introducing Extension Methods
This method is an extension of the string-class. It reverts a string in a very efficient way and it is widely used around the world.
Faster methodes use either unsafe code or only work fast on very short strings.
1 2 3 4 5 6 7 8 9 |
public static class StringExtension { public static string Revert(this string str) { char[] c = str.ToCharArray(); Array.Reverse(c); return new string(c); } } |
Share :
How to save multiple numbers into one byte How to use Method Parameters ref, out, params
Comments are currently closed.