Printing a number in hexa decimal..

N

Nadav

Hi,

How can I use C# to print a number in hexadecimal e.g. printf(" %x "); or
print 15 ( decimal ) as 'F' (hexa)
Can a number be printed as binary as-well?

Thanks in advance,
Nadav.
 
M

Miha Markic

string.Format("{0:X}", 24);
(X or x will output hex string).
For a more flexible formating you should use Convert.ToString(number, base)
method.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top