Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / Languages / C#4.0

Reverse of a string without using the Reverse function in C# and VB

5.00/5 (3 votes)
23 Jul 2011CPOL 10.5K  
I wouldn't create a class for this. I'd make it an extension method, and then do this:public static class String Extensions{ public static string Reverse(this string value) { value = // do your reverse code here; return value; }}// Usage:string x...
I wouldn't create a class for this. I'd make it an extension method, and then do this:

C#
public static class String Extensions
{
    public static string Reverse(this string value)
    {
        value = // do your reverse code here;
        return value;
    }
}

// Usage:

string x = "reverse";
x = x.Reverse();

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)