C# - Math.PI Property with Example

In this tutorial, we will learn about the C# Math.PI property with its definition, usage, syntax, and example. By Nidhi Last updated : March 29, 2023

C# Math.PI Property

The Math.PI property is used to return the value of PI.

Syntax

double Math.PI;

Parameter(s)

  • None

Return Value

It returns the value of PI constant.

C# Example of Math.PI Property

The source code to demonstrate the use of PI property of Math class (In this program, we are going to calculate the area of circle using the PI property.) is given below. The given program is compiled and executed successfully.

using System;

class Sample {
  //Entry point of Program
  static public void Main() {
    double AreaOfCircle = 0.0;
    int radius = 12;

    AreaOfCircle = (Math.PI * radius * radius);

    System.Console.WriteLine("Area of Circle: " + AreaOfCircle);
  }
}

Output

Area of Circle: 452.38934211693
Press any key to continue . . .

C# Math Class Programs »


Comments and Discussions!

Load comments ↻






Copyright © 2024 www.includehelp.com. All rights reserved.