How to use Byte.ToString to get HEX string?

  • Thread starter Thread starter gg
  • Start date Start date
G

gg

Hello, every body:
in C++ we can use springf("02X",byte) to get the string like following:
"0D","AB","9C"...
but in C# i use Byte.ToString("X") can get "D","AB","9C"...
how to get like "0D"?

Thanks.
 
Hello, every body:
in C++ we can use springf("02X",byte) to get the string like following:
"0D","AB","9C"...
but in C# i use Byte.ToString("X") can get "D","AB","9C"...
how to get like "0D"?

If you always want two digits:

ToString("X2")
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top