469,898 Members | 1,779 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,898 developers. It's quick & easy.

Hex with .ToString("X")

Hi All,

I am trying to display an int as it' sHex representation, and looking on
MSDN it appears this can be done with .ToString("X").

This does work, but the example on MSDN
(http://msdn.microsoft.com/library/de...tringtopic.asp)
the int is formatted with leading 0's to make an 8 char string, but when I
use it there are no leading 0's.

Does anyone know how I can get the leading 0's?

Thanks,
Steve
Nov 17 '05 #1
1 39161
You need to use .ToString ("X4");

The 4 represents the number of leading zeros to include where necessary.

"Steve Norman" wrote:
Hi All,

I am trying to display an int as it' sHex representation, and looking on
MSDN it appears this can be done with .ToString("X").

This does work, but the example on MSDN
(http://msdn.microsoft.com/library/de...tringtopic.asp)
the int is formatted with leading 0's to make an 8 char string, but when I
use it there are no leading 0's.

Does anyone know how I can get the leading 0's?

Thanks,
Steve

Nov 17 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

14 posts views Thread by dale zhang | last post: by
5 posts views Thread by Dan C Douglas | last post: by
6 posts views Thread by John | last post: by
15 posts views Thread by Brady Love | last post: by
16 posts views Thread by mj.redfox.mj | last post: by
2 posts views Thread by Henry Stock | last post: by
1 post views Thread by Waqarahmed | last post: by
reply views Thread by Salome Sato | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.