C++
char* Byte2Hex(unsigned char Byte)
{
char _s[] = { '0', '1', '2','3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' };
char* _ret = new char[0x2];
_ret[0x0] = _s[Byte / 0x10];
_ret[0x1] = _s[Byte % 0x10];
return _ret;
}
// 利用 std::string 更简单,不过无所谓
C#
string Byte2Hex(byte Byte)
{
string _ret = null, _s = "0123456789ABCDEF";
_ret = _s[Byte / 0x10].ToString();
_ret += _s[Byte % 0x10].ToString();
return _ret;
}