How do I get the 48 least significant bits of a long formatted as hex?
long number = …;
// string should contain exactly 12 characters
string leastSignificant48bitsOfNumberAsHex = nu开发者_如何学JAVAmber.ToString("????")
You can do it with string formatting:
string leastSignificant48bitsOfNumberAsHex = String.Format("{0:X012}", number & 0xFFFFFFFFFFFF);
This will fill up the string with zeroes if the number is shorter.
精彩评论