C# Hexadecimal conversion

  • Thread starter Thread starter Guest
  • Start date Start date
Use the ToString() method with the correct format specifier.
int x = 10;
Console.WriteLine(x.ToString("x"));
 
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.
 
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?
 
Back
Top