001
001

Reputation: 65137

convert 10 digit number to hex string

How do I convert a 10 digit number to a hex string in c#?

Note: if the number is less than 10 digits, I want to add padding? example the number is 1, I want my string to be 0000000001.

Upvotes: 2

Views: 1098

Answers (1)

Oded
Oded

Reputation: 499002

Use a standard format string:

string paddedHex = myNumber.ToString("x10");

See the x format specifier.

Upvotes: 6

Related Questions