.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Imran Ghani
Sohaib Khalid

Home >> Code Snippets >> Collections >> Post New Resource Bookmark and Share   

 Subscribe to Code Snippets

String extension methods

Posted By:Blessy Baby       Posted Date: February 07, 2011    Points: 15    Category: Collections    URL: http://www.dotnetspark.com  

You can create addition methods for string types without modifying existing methods.

Here see some string extension methods

1. Convert to base64string

       public static string ToBase64String(this string value)
            byte[] toEncodeAsBytes = System.Text.ASCIIEncoding.ASCII.GetBytes(value);
            return System.Convert.ToBase64String(toEncodeAsBytes);
2. Convert from base63string

     public static string FromBase64String(this string value)
            byte[] encodedDataAsBytes = System.Convert.FromBase64String(value);
            return System.Text.ASCIIEncoding.ASCII.GetString(encodedDataAsBytes);


Further Readings:


No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More code samples in C#, ASP.Net, Vb.Net and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend