Illustrates the use of constants : Constant « Language Basics « C# / C Sharp






Illustrates the use of constants

Illustrates the use of constants
/*
Mastering Visual C# .NET
by Jason Price, Mike Gunderloy

Publisher: Sybex;
ISBN: 0782129110
*/

/*
  Example2_7.cs illustrates the use of constants
*/

public class Example2_7
{

  public static void Main()
  {

    const int Length = 3;

    // mathematical constant pi
    const double Pi = 3.14159;

    // speed of light in meters per second
    const double SpeedOfLight = 2.99792e8;

    System.Console.WriteLine(Length);
    System.Console.WriteLine(Pi);
    System.Console.WriteLine(SpeedOfLight);

  }

}

           
       








Related examples in the same category

1.Illustrates the use of a const fieldIllustrates the use of a const field