Understanding Hexadecimal

Hexadecimal is the base 16 number system. Hexadecimal is used to divide a byte into two values of 4 bits each. Said another way, a byte (8 bits) is two hexadecimal digits ranging from 00 to FF.

The byte 10111111 is the hexadecimal number BF, and the byte 00100100 is the hexadecimal number 24.

Decimal, Binary, Hexadecimal Table Conversion

How to convert hexadecimal string to integer:

C#

string hexString = "8E2";
int number = Int.32.Parse(hexString, System.Globalization.NumberStyles.HexNumber);
Console.WriteLine(number);
//2274


byte[] vals = {0x01, 0xAA, 0xB1, 0xDC, 0x10, 0xDD}
string hexString = Convert.ToHexString(vals);
int number = Int.32.Parse(hexString, System.Globalization.NumberStyles.HexNumber);
Console.WriteLine(number);
//1832640057565

How to convert integer to hexadecimal string:

C#

int number = 200;
string hexString = number.ToString("X");

References:

Code: The Hidden Language of Computer Hardware and Software, 2nd Edition by Charles Petzold

https://learn.microsoft.com/en-us/dotnet/csharp/programming-guide/types/how-to-convert-between-hexadecimal-strings-and-numeric-types

--

--