![]()
One of the values in the following table.
Zero or positive The positive square root of d.
Negative Equals double.NaN Equals double.PositiveInfinity
The following example demonstrates using the Math.Sqrt(double) method.
C# Example
using System;
public class MathSqrtExample
{
public static void Main()
{
Double d1 = Math.Sqrt(16.0);
Double d2 = Math.Sqrt(0.0);
Double d3 = Math.Sqrt(-10.0);
Console.WriteLine("Math.Sqrt(16.0) returns {0}", d1);
Console.WriteLine("Math.Sqrt(0.0) returns {0}", d2);
Console.WriteLine("Math.Sqrt(-10.0) returns {0}", d3);
}
}
The output is
Math.Sqrt(16.0) returns 4