C# Math Sqrt

Description

Math Sqrt returns the square root of a specified number.

Syntax

Math.Sqrt has the following syntax.


public static double Sqrt(
  double d
)

Parameters

Math.Sqrt has the following parameters.

  • d - The number whose square root is to be found.

Returns

Math.Sqrt method returns One of the values in the following table. d parameter Return value Zero or positive The positive square root of d. Negative NaN Equals NaN NaN Equals PositiveInfinity PositiveInfinity

Example

The following code shows how to use Math.Sqrt method.


using System;/*from  w w  w.j a va  2 s.  c  o m*/

public class MainClass{
  public static void Main(String[] argv){  

    
    System.Console.WriteLine(Math.Sqrt(0.5));

  }
}

The code above generates the following result.





















Home »
  C# Tutorial »
    System »




Array
BitConverter
Boolean
Byte
Char
Console
ConsoleKeyInfo
Convert
DateTime
DateTimeOffset
Decimal
Double
Enum
Environment
Exception
Guid
Int16
Int32
Int64
Math
OperatingSystem
Random
SByte
Single
String
StringComparer
TimeSpan
TimeZone
TimeZoneInfo
Tuple
Tuple
Tuple
Type
UInt16
UInt32
UInt64
Uri
Version