Mega Code Archive

 
Categories / C# / Language Basics
 

Illustrates the use of a const field

/* Mastering Visual C# .NET by Jason Price, Mike Gunderloy Publisher: Sybex; ISBN: 0782129110 */ /*   Example6_2.cs illustrates the use of a const field */ // declare the Car class class Car {   // declare a const field   public const int wheels = 4; } public class Example6_2 {   public static void Main()   {     System.Console.WriteLine("Car.wheels = " + Car.wheels);     // Car.wheels = 5;  // causes compilation error   } }