Sunday, January 13, 2008

convert a string to a byte array and convert a byte array to a string

The .Net framework offers a quite easy way to handle this:

convert a string to a byte array:
byte[] buffer = System.Text.Encoding.ASCII.GetBytes("any string you like, e.g: indeXus.Net Shared Cache - the distributed caching solution");

convert a byte array to a string:
string fromByteArray = System.Text.Encoding.ASCII.GetString(buffer);
Console.WriteLine(fromByteArray);

Result will be:
"any string you like, e.g: indeXus.Net Shared Cache - the distributed caching solution"

No comments:

Shared Cache - .Net Caching made easy

All information about Shared Cache is available here: http://www.sharedcache.com/. Its free and easy to use, we provide all sources at codeplex.

Facebook Badge