Valhalla Legends Archive

Programming => General Programming => .NET Platform => Topic started by: mentalCo. on February 03, 2005, 02:59 PM

Title: [c#.net] converting from dec to hex [solved]
Post by: mentalCo. on February 03, 2005, 02:59 PM
This is a simple and dumb question.  I can't get a dec value to display hex in a rich text box. 

[edit]

solved it using '.ToString("x")'  im a retard.
Title: Re: [c#.net] converting from dec to hex [solved]
Post by: MyndFyre on February 03, 2005, 06:12 PM
Just a side note, you can use "x2" or the like to specify the number of left-padded 0s to include.  For example, if you have the number 0xe0543, and you call .ToString("x8"), it will format 000e0543.  Capitalizing the X results in capital letters in the number.  ;)

The same rules can be applied to String.Format -- if you use the command:

Console.WriteLine("Number 1: {0:x2}\nNumber 1: {0:X8}", 0x9e);

the console output would be:

9e
0000009E


:)  cheers