...

/

Math Class

Math Class

Use the Math class to perform mathematical calculations.

Introduction

We occasionally need to perform some mathematical calculations inside our programs. We may even want to create our own calculator. .NET provides us with the necessary tools out of the box.

The System namespace contains a static class called Math with methods for performing various mathematical operations.

For instance, we could obtain the square root of a number by simply calling the Math.Sqrt() method.

Note: he Math class is static, so all its members are also static. We use the class’ methods without instantiating it.

The Math class includes many methods, so it’s impossible to cover them all. We’ll see some of them in our examples, though. Here are some of the most popular:

  • Math.Pow(): This
...