How to convert decimal number to hexadecimal in C# using method

    using System;
    using System.Text;

    class DecToHex
    {
        static void Main(string[] args)
        {
            long num = 100000;
            Console.WriteLine(DecimalToHex(num)); // 186A0
        }

        private static string DecimalToHex(long num)
        {
            var res = new StringBuilder();
            while (num > 0)
            {
                var reminder = num % 16;
                if (reminder > 9)
                {
                    res.Insert(0, (char)(reminder + 55));
                }
                else
                {
                    res.Insert(0, reminder);
                }

                num /= 16;
            }

            return res.ToString();
        }
    }