Newbie question

H

Harald Dietewich

Hi, is there any "simple" solution (function in C#) for converting a hex
string into an int?

Example: Want to convert "0x8A33EB1C" into the int value 2318658332

Thanks in advance!
- Harald
 
J

Jon Skeet

Harald Dietewich said:
Hi, is there any "simple" solution (function in C#) for converting a hex
string into an int?

Example: Want to convert "0x8A33EB1C" into the int value 2318658332

Look at Convert.ToInt32 (string, int)

Note, however, that the value you specified is out of the range of a
signed int. Casting the returned int to uint will do what you want, but
unsigned ints aren't CLS-compliant, if that's an issue for you.
 
E

Eliyahu Goldin

// not tested!!!
Int64.Parse (strVar, System.Globalization.NumberStyles.HexNumber);

Eliyahu
 

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