Hi everyone, welcome back. In these examples, we will be going over the constants that are included within the C# math class. The math class is a class that is provided by C# that contains mathematical functions that can be used in your project. We will be going over the constants that are provided within the math class. With this introduction out of the way, let’s get into it.
E Constant
Let’s start by going over the E or Euler’s number constant. We can access this value by calling the E constant in the math class. Let’s see an example:
Console.WriteLine(Math.E);Output:
2.718281828459045
In the example above, we can see that we are successfully retrieving the E constant from the math class.
Pi Constant
Now, let’s see how we can access the pi constant. We can access this value by calling the pi constant in the math class. Let’s see an example:
Console.WriteLine(Math.PI);Output:
3.141592653589793
In the example above, we can see that we are successfully retrieving the pi constant from the math class.