Turn byte into two-digit hexadecimal number just using ToString?

I can turn a byte into a hexadecimal number like this:

myByte.ToString("X")

but it will have only one digit if it is less than 0x10. I need it with a leading zero. Is there a format string that makes it possible to do this in a single call to ToString?


Solution 1:

myByte.ToString("X2") I believe.