class Constants { public const int A = 1; public const int B = A + 1; }shows a class named Constants that has two public constants. Even though constants are considered static members, a constant declaration neither requires nor allows the modifier static. Constants can be accessed through the class, as in
using System; class Test { static void Main() { Console.WriteLine("{0}, {1}", Constants.A, Constants.B); } }which prints out the values of Constants.A and Constants.B, respectively.
| |
Jagger Software Ltd | |
Company # 4070126 | |
VAT # 762 5213 42 |