Hex -> Dec & Dec -> Hex
-
Tuesday, March 06, 2007 5:14 AM
Does anyone have idea how to implement methods for converting hex number to dec number, and also converting from dec number to hex number?
Thanks
Mike
All Replies
-
Tuesday, March 06, 2007 5:36 AM
I found a good code sample at:
http://www.geekpedia.com/Question8_How-do-I-convert-from-decimal-to-hex-and-hex-to-decimal.html
// Store integer 182
int decValue = 182;
// Convert integer 182 as a hex in a string variable
string hexValue = decValue.ToString("X");
// Convert the hex string back to the number
int decAgain = int.Parse(hexValue, System.Globalization.NumberStyles.HexNumber); -
Tuesday, July 24, 2012 1:08 PM
If you want a custom C# implementation that can convert a number from any numeral system to decimal and vice versa, take a look at the following articles:

