Variable (iUserNum2) does not exist in the current context in PowerOf function in C#
<p>/* Hello I am a student trying to do some practice programming tasks, but I can't seem to get one of my variables to work in a function, I need the value of the variable to be inputted by the user, but it wants we to declare it inside the PowerOf function rather than the Main function, sorry to be a n00b, but any help would be greatly appreciated. [:*/</p>

<pre><code>using System;

namespace ThePowerOf
{
    class MainClass
    {
        public static void Main (string[] args)
        {

            string sUserInput;
            int iUserNum1 = 0;
            int iUserNum2 = 0;
            int iPower = 0;

            Console.WriteLine ("Enter a number");
            sUserInput = Console.ReadLine();
            iUserNum1 = Int16.Parse(sUserInput);

            Console.WriteLine ("Enter a number");
            sUserInput = Console.ReadLine();
            iUserNum2 = Int16.Parse(sUserInput);

            iPower = PowerOf(iUserNum1);

            Console.WriteLine((iUserNum1) + (" To the power of ") + (iUserNum2) + (" = ") + (iPower));
            Console.ReadLine();

        }

        static int PowerOf(int iUserNum1)

        {   

        for (int i = 0; i &lt; iUserNum2; ++i)

        {

        iUserNum1 = (iUserNum1 * iUserNum1);

        }       

        return iUserNum1;   

        }

    }
}
</code></pre>
