Converting Byte Arrays to Strings (C#)

It’s a lot easier than you think!
 
This is as much as a reminder to myslef as a helpful hint for other people. If you need to convert a byte array to a string the you can use the System.BitConverter class and the ToString() method which accepts a byte array as a parameter. For more information have a look at http://msdn.microsoft.com/en-us/library/system.bitconverter.aspx 
 
I used this for debugging SQL Server Timestamp columns so that I could get a more readable version of the column contents.
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s