How to convert Hex to decima

I have hex string, such as AA or 3D...
I want to convert it to decimal number, when i using this code, it run not OK:
string hexString = "AA";
long HR = Convert.ToInt64(hexString, 16) + 300;
HR = HR/10;
txtHR.Text = HR.ToString();
Is there any code to help me
If I want to display var HR as full nuber such as .. 45.7 or 38.9, how can I modify code Becase txtHR.Text = HR.ToString(); alway remove digital after " . "

Thank you!






Answer this question

How to convert Hex to decima

  • waison

    Thank you,

    I had done when using float var.

    BB


  • sansara13

    long is for integers, use float instead.

  • jehan

    try this:

    string hex = "3D";

    int dec = int.Parse(hex, System.Globalization.NumberStyles.HexNumber);

    Console.WriteLine(dec.ToString());

    Edgar


  • How to convert Hex to decima