C# Tutorial C# Advanced C# References

C# Math - PI Field



The C# PI field is used to return the value of 𝜋 to the available precision. It returns the value of 𝜋 as 3.1415926535897931.

Syntax

public const double PI = 3.1415926535897931;

Parameters

No parameter is required.

Return Value

Returns the value of 𝜋 to the available precision.

Example:

In the example below, Math.PI constant is used to return the value of 𝜋 to the available precision.

using System;

class MyProgram {
  static void Main(string[] args) {
   double pi = Math.PI;
   Console.WriteLine("Math.PI = " + pi);
   Console.WriteLine(
      "Area of the circle with radius 1.0 is: " + pi*1*1);
  }
}

The output of the above code will be:

Math.PI = 3.14159265358979
Area of the circle with radius 1.0 is: 3.14159265358979

❮ C# Math Methods

5