long number = …;
// string should contain exactly 12 characters
string leastSignificant48bitsOfNumberAsHex = number.ToString("????")
答案 0 :(得分:4)
您可以使用字符串格式化来执行此操作:
string leastSignificant48bitsOfNumberAsHex = String.Format("{0:X012}", number & 0xFFFFFFFFFFFF);
如果数字较短,这将用零填充字符串。