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

有帮助吗?

解决方案

You could use the ToString method:

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

其他提示

try this :

  byte[] b1 = ...

  string h = System.Text.Encoding.UTF8.GetString(b1);
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top