Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Converting 0xf to int 1

Status
Not open for further replies.

AT76

Technical User
Joined
Apr 14, 2005
Messages
460
Location
US
Hello, Could someone give me an example of how to convert 0xf to an int?

Thanks!
 
Thanks B00gyeMan, but it's still returning 0xf. Any ideas?
 
I did the code exactly as B00gyeMan listed it and I got int i to store 15, based on the conversion.

----------------------------------------

TWljcm8kb2Z0J3MgIzEgRmFuIQ==
 
byte b = 0xf;

int i = Convert.ToInt32(b);


Maybe something like that? I don't see why the i = 0xf; wouldn't work.
 
Is this 0xf starting off as a string? aka: "0xf"

Chip H.


____________________________________________________________________
If you want to get the best response to a question, please read FAQ222-2244 first
 
Hi chiph... Yes, It starts as a string.
 
You can use the Int32.Parse method, and you'll have to use the overload where you specify a NumberStyles enumeration of AllowHexSpecifier. You'll also have to strip off the "0x" part of your string using the string.Substring method before passing it to the Parse method.

Chip H.


____________________________________________________________________
If you want to get the best response to a question, please read FAQ222-2244 first
 
Awesome chip! That was exactly what I needed!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top