How to convert hex number to integer (int) number in C#

1 Answer

0 votes
using System;
using System.Globalization;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            String hex = "47C5E3";
            
            int i = int.Parse(hex, NumberStyles.HexNumber);
            Console.WriteLine("{0} in hex = {1} in decimal (int)", hex, i); // 4703715

            i++;
            Console.WriteLine(i); // 4703716
        }
    }
}

/*
run:
 
47C5E3 in hex = 4703715 in decimal (int)
4703716

*/


answered Feb 16, 2015 by avibootz
edited Mar 19, 2015 by avibootz

Related questions

1 answer 182 views
3 answers 320 views
1 answer 184 views
1 answer 102 views
1 answer 228 views
228 views asked Mar 24, 2015 by avibootz
...