List Info

Thread: C-Sharp (C#) Group: Convert int to hex




C-Sharp (C#) Group: Convert int to hex
user name
2006-08-23 20:04:10
What is the tidiest way to convert an int32 to a four-digit
hex?  I can
convert it to hex easily using ToString("X"),
but if x=15 it converts
to "F".  I want to convert it to
"000F".

Thanks.


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "C-Sharp (C#)" group.
To post to this group, send email to C_Sharpgooglegroups.com
To unsubscribe from this group, send email to
C_Sharp-unsubscribegooglegroups.com
For more options, visit this group at http://groups.
google.com/group/C_Sharp
-~----------~----~----~----~------~----~------~--~---

C-Sharp (C#) Group: Re: Convert int to hex
user name
2006-08-23 20:25:56
intvalue.ToString("X").PadLeft(4, '0') should get you 000F for an integer value of 15.

Of course there are int values that go up to 7FFFFFFF in hex, but the four spaces should cover all values 0FFF and lower.

On 8/23/06, Davy B <itv.com">david.bridgeitv.com&gt; wrote:

What is the tidiest way to convert an int32 to a four-digit hex?  I can
convert it to hex easily using ToString(&quot;X";), but if x=15 it converts
to "F&quot;. &nbsp;I want to convert it to "000F".

Thanks.



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "C-Sharp (C#)" group.
To post to this group, send email to C_Sharpgooglegroups.com
To unsubscribe from this group, send email to C_Sharp-unsubscribegooglegroups.com
For more options, visit this group at http://groups.google.com/group/C_Sharp
-~----------~----~----~----~------~----~------~--~---

[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )