To calculate the power exponent value, use the Math.pow() method.
Here, n is the number and p is the power −
double res = Math.Pow(n, p);
The following is the complete code −
Example
using System;
class Program {
static void Main() {
double n, p;
n = 7;
p = 3;
Console.WriteLine("Exponent Power= "+n);
double res = Math.Pow(n, p);
Console.WriteLine("Result= {0}", res);
Console.ReadLine();
}
}Output
Exponent Power= 7 Result= 343