[Edit]
+
0
-
0

C# calculate square root with Math.Pow() method

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
using System; public class Program { static double CalculateSqrt(double value) { return Math.Pow(value, 0.5); } public static void Main(string[] args) { // Examples: Console.WriteLine( CalculateSqrt( 4 ) ); // 2 Console.WriteLine( CalculateSqrt( 9 ) ); // 3 Console.WriteLine( CalculateSqrt( 2 ) ); // 1.4142135623730951 Console.WriteLine( CalculateSqrt( 0.5 ) ); // 0.7071067811865476 Console.WriteLine( CalculateSqrt( 0 ) ); // 0 Console.WriteLine( CalculateSqrt( -1 ) ); // NaN } }