Double - Pow
Returns a specified number raised to the specified power.
public static void Main() { double value = 2.5; for (int power = 0; power <= 10; power++) { // C# Extension Method: Double - Pow var result = value.Pow(power); Console.WriteLine("{0}^{1} = {2:N2}", value, power, result); } }
View Source
using System; public static partial class Extensions { /// <summary> /// Returns a specified number raised to the specified power. /// </summary> /// <param name="x">A double-precision floating-point number to be raised to a power.</param> /// <param name="y">A double-precision floating-point number that specifies a power.</param> /// <returns>The number raised to the power .</returns> public static Double Pow(this Double x, Double y) { return Math.Pow(x, y); } }