ToString(“X”) produces single digit hex numbers

前端 未结 2 860
粉色の甜心
粉色の甜心 2020-12-31 01:05

We wrote a crude data scope.

(The freeware terminal programs we found were unable to keep up with Bluetooth speeds)

The results are okay, and we are writing

相关标签:
2条回答
  • 2020-12-31 01:19

    "X" is a format specifier. It converts a number to a string of hexadecimal digits.

    int _abc = 123456;
    Console.WriteLine(_abc.ToString("X"));
    

    This will give you '1E240' as output

    ( 1E240 is the hexadecimal value of 123456 )

    0 讨论(0)
  • 2020-12-31 01:26

    Use a composite format string:

    pass += b[i].ToString("X2") + " ";
    

    The documentation on MSDN, Standard Numeric Format Strings has examples.

    0 讨论(0)
提交回复
热议问题