How to convert a number to hex string in C#

1 Answer

0 votes
using System;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            try
            {
                int i = 261642;

                string hex = i.ToString("X8");
                Console.WriteLine(hex); // 0003FE0A
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
    }
}

/*
run:
 
0003FE0A

*/


answered Mar 24, 2015 by avibootz

Related questions

1 answer 103 views
1 answer 267 views
1 answer 73 views
73 views asked Nov 19, 2024 by avibootz
2 answers 147 views
3 answers 321 views
1 answer 69 views
1 answer 95 views
...