Andy McCluggage Andy McCluggage - 1 year ago 34
C# Question

How to convert numbers between hexadecimal and decimal in C#?

How do you convert between hexadecimal numbers and decimal numbers in C#?

Answer Source

To convert from decimal to hex do...

string hexValue = decValue.ToString("X");

To convert from hex to decimal do either...

int decValue = int.Parse(hexValue, System.Globalization.NumberStyles.HexNumber);

or

int decValue = Convert.ToInt32(hexValue, 16);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download