Converting a Byte Value into a Hexadecimal String
|
1 2 3 4 5 6 7 8 |
public static string ByteToHex(byte b) { const string hex = "0123456789ABCDEF"; int lowNibble = b & 0x0F; int highNibble = (b & 0xF0) >> 4; string s = new string(new char[] { hex[highNibble], hex[lowNibble] }); return s; } |