0Pricing
C# Academy · Lesson

The Math Class

Round, sqrt, pow, and friends.

Meet the Math Class

The System.Math class provides ready-made mathematical functions and constants.

Its members are static, so you call them on the class itself, like Math.Sqrt(16), without creating an object.

double root = Math.Sqrt(16);
Console.WriteLine(root);

Powers and Roots

Math.Pow(x, y) raises x to the power y, and Math.Sqrt(x) returns the square root.

Both return a double, even when the inputs are whole numbers.

Console.WriteLine(Math.Pow(2, 10));
Console.WriteLine(Math.Sqrt(144));

All lessons in this course

  1. Numeric Types
  2. Arithmetic and Precedence
  3. The Math Class
  4. Converting Between Numbers
← Back to C# Academy