Hexadecimal To Decimal
This algorithm converts hexadecimal numbers to decimal numbers.
public static int HexadecimalToDecimal(string hex)
{
hex = hex.ToUpper();
int hexLength = hex.Length;
double dec = 0;
for (int i = 0; i < hexLength; ++i)
{
byte b = (byte)hex[i];
if (b >= 48 && b <= 57)
b -= 48;
else if (b >= 65 && b <= 70)
b -= 55;
dec += b * Math.Pow(16, ((hexLength - i) - 1));
}
return (int)dec;
}
Example
string data = "7660F";
int value = HexadecimalToDecimal(data);
Output
484879