disable broken tests on net_4_0
[mcs.git] / docs / ecma334 / 8.7.1.xml
blob8fed2f146a0b6f4fd36daee89002b3b0913fdafa
1 <?xml version="1.0"?>
2 <clause number="8.7.1" title="Constants" informative="true">
3   <paragraph>A constant is a class member that represents a constant value: a value that can be computed at compile-time. Constants are permitted to depend on other constants within the same program, as long as there are no circular dependencies. The rules governing constant expressions are defined in <hyperlink>14.15</hyperlink>. The example <code_example><![CDATA[
4 class Constants  
5 {  
6    public const int A = 1;  
7    public const int B = A + 1;  
8 }  
9 ]]></code_example>shows a class named Constants that has two public constants. </paragraph>
10   <paragraph>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 <code_example><![CDATA[
11 using System;  
12 class Test  
13 {  
14    static void Main() {  
15       Console.WriteLine("{0}, {1}", Constants.A, Constants.B);  
16    }  
17 }  
18 ]]></code_example>which prints out the values of Constants.A and Constants.B, respectively. </paragraph>
19 </clause>