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 205 views
1 answer 374 views
1 answer 171 views
171 views asked Nov 19, 2024 by avibootz
2 answers 286 views
3 answers 502 views
1 answer 164 views
164 views asked Mar 6, 2025 by avibootz
1 answer 197 views
...