Can someone help me better understand this code. The point of this function is to have user input numbers and the program returns the numbers reversed : Can someone help me better understand this code. The point of this function is to have user input numbers and the program returns the numbers reversed. I'm just curious to know how it works, what exactly in the reverse function is doing the reversing? I tried doing the math but i keep hitting a roadblock.

        class Program
    {
        static void Main(string[] args)
        {
            int n = 0, result = 0;

            Console.WriteLine("Please Enter a Number: ");
            n = Convert.ToInt32(Console.ReadLine());

            result = reverse(n);
            Console.WriteLine("The Reverse Number Is : " + result);



            Console.ReadKey();        
        }

        public static int reverse(int n)
        {
            int temp = 0, rev = 0;

            while( n != 0)
            {
                temp = n % 10;
                rev = (rev * 10) + temp;
                n = n / 10;

            }

            return rev;
        }

    }
}