十进制到十六进制有符号 2 转换器

Decimal to Hex signed 2 Converter

我想将一个值转换为十六进制,但缺少结果。

        int q = 0006038738;
        var w = q.ToString("X");
        //result: 5C24D2
        //I want that: 005C24D2

如何在要转换的值的开头加入 0?

试试这个:

var w = q.ToString("X8");

The precision specifier indicates the minimum number of digits desired in the resulting string. If required, the number is padded with zeros to its left to produce the number of digits given by the precision specifier.

参考:The Hexadecimal ("X") Format Specifier