Mega Code Archive

 
Categories / C# Book / 01 Language Basics
 

0099 const value

We can use const modifier to indicate that a field is a constant. The following Math class has a constant field PI. class Math { public const double PI = 3.14; } const field can be used in a method. using System; class Program { static void Main(string[] args) { const double PI = 3.14; Console.WriteLine(2 * PI); } } The output: 6.28