Convert byte data to string output like in hex editor
-
04-06-2021 - |
Pergunta
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:
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
Solução
You could use the ToString method:
public static string ToString(byte[] buffer)
{
return BitConverter.ToString(buffer);
}
Outras dicas
try this :
byte[] b1 = ...
string h = System.Text.Encoding.UTF8.GetString(b1);
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow