Question

I’m looking for method that will return string representation of byte data just like hex editor can. It should have one parameter which is byte[] and returns string like the following: Like it should be

This method should handle escape characters, nulls and align text properly. I want to use it in Debug.WriteLine(). Please help me with this! Thanks!

Update: Ok. Thank you all guys. Here is a link for a ready to use solution http://illegalargumentexception.blogspot.fr/2008/04/c-file-hex-dump-application.html by Darin Dimitrov

Was it helpful?

Solution

You could use the ToString method:

public static string ToString(byte[] buffer)
{
    return BitConverter.ToString(buffer);
}

OTHER TIPS

try this :

  byte[] b1 = ...

  string h = System.Text.Encoding.UTF8.GetString(b1);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top