C# Hexadecimal conversion

G

Guest

Hi,

I want to WriteLine a number in hexadecimal ( e.g. %x ), how would I do that
in C#?
 
S

sadhu

Use the ToString() method with the correct format specifier.
int x = 10;
Console.WriteLine(x.ToString("x"));
 
J

Jon Sagara

int nNum = 15;
Console.WriteLine ("Hex: {0:X}", nNum); // F
Console.WriteLine ("Hex: {0:x}", nNum); // f

X produces upper case hex, x produces lower case hex.
 
M

Mark Reed

int nNum = 15;
Console.WriteLine ("Hex: {0:X}", nNum); // F
Console.WriteLine ("Hex: {0:x}", nNum); // f

X produces upper case hex, x produces lower case hex.

I'm a beginner, so pardon the simplicity of what I am about to ask...

Using this same goal, how would you make a form to input a word and have it
converted to hex and displayed in a label once a button is pressed?
 

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

Similar Threads

Hexadecimal to Binary 11
96 bit binary to hexadecimal conversion 2
HexaDecimal 1
Hex() in C# 8
Printing a number in hexa decimal.. 2
Numerals conversion 2
Hexadecimal numbers from Active directory 1
Convert numerals 11

Top