The Math.Pow() method returns a number raised to the power of a second number.


Math.Pow(num1, num2)

Math.Pow() takes two values of type double. It will return a double that is the result of the value num1 raised to the power of value num2.


The following example demonstrates the Math.Pow() method and writes the result to the console.

using System;
public class Example {
public static void Main (string[] args) {
double d1 = 8, d2 = 3;
Console.WriteLine("8^3 = " + Math.Pow(d1,d2));

This example results in the following output:

8^3 = 512


Interested in helping build Docs? Read the Contribution Guide or share your thoughts in this feedback form.

Learn C# on Codecademy