Use expressions to calculate and display the circumference of a circle : const « Class « C# / CSharp Tutorial






class MainClass
{

  public static void Main()
  {

    const double Pi = 3.14159;
    double diameter = 2.5;

    double circumference = Pi * diameter;

    System.Console.WriteLine("Circumference = " + circumference);

  }

}
Circumference = 7.853975








7.35.const
7.35.1.Define constants with const keywords
7.35.2.Local Constants
7.35.3.The use of 'const int'
7.35.4.Use expressions to calculate and display the circumference of a circle