Possible Duplicate:
How to convert numbers between hexadecimal and decimal in C#?
I need to be able to take a hexadecimal string and convert it into actual hexadecimal value in .NET. How do I do this?
For instance, in Delphi, you can take string of "FF" and add the dollar sign as follow to it.
tmpstr := '$'+ 'FF';
Then, convert tmpstr
string variable into an integer to get the actual hexidecimal. The result would be 255
.
Assuming you are trying to convert your string
to an int
:
var i = Int32.Parse("FF", System.Globalization.NumberStyles.HexNumber)
Your example 1847504890
does not fit on an int
, however. Use a longer type instead.
var i = Int64.Parse("1847504890", System.Globalization.NumberStyles.HexNumber)
Very simple:
int value = Convert.ToInt32("DEADBEEF", 16);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With