Local Constants : const « Class « C# / CSharp Tutorial






using System;

class MainClass
{
   static void Main()
   {
      const double PI = 3.1416;
      double area = 2 * 2 * PI;
      
      Console.WriteLine("Radius: {0}, Area: {1}", 2, area);
   }
}
Radius: 2, Area: 12.5664








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