Integer to Hex

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,
I want to convert an integer (actuallu the ascii value of a character) to its equivalent Hex value. Can someone suggest, which is the easiest way to do it.

Thanks in advance,
Al.
 
String.Format( "{0:X2}", intValue)

--
Floyd Burger

Al Sav said:
Hi,
I want to convert an integer (actuallu the ascii value of a character) to
its equivalent Hex value. Can someone suggest, which is the easiest way to
do it.
 
Al,

Try something like

string hexString = String.Format("{0:x2}", intVal);

Paul Qualls

Al Sav said:
Hi,
I want to convert an integer (actuallu the ascii value of a character) to
its equivalent Hex value. Can someone suggest, which is the easiest way to
do it.
 
for (int i = 0; i < 16; i++)
Console.WriteLine(Convert.ToString(i,16));

Al Sav said:
Hi,
I want to convert an integer (actuallu the ascii value of a character) to
its equivalent Hex value. Can someone suggest, which is the easiest way to
do it.
 
string.Format("0x{0:x}", i)
??




Al Sav said:
Hi,
I want to convert an integer (actuallu the ascii value of a character) to
its equivalent Hex value. Can someone suggest, which is the easiest way to
do it.
 
Thanks for all the response and different methods.

I ended up using this:
((int) c).ToString("x")

c is a char.

I am surprised to see so many different solutions, whereas I was trying so hard to find a solution.
Alwin S.
 
Back
Top