Published Feb 27, 2023Updated Apr 29, 2023
Contribute to Docs

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

Codebyte Example

The following example is runnable and uses the Math.Pow() method to return a double type value of 2 raised to the power of 10:

Visit us
Hide code
Hide output
Hide output

All contributors

Looking to contribute?

Learn C# on Codecademy