disable broken tests on net_4_0
[mcs.git] / docs / ecma334 / 17.4.2.2.xml
blobd4acac3306c14e828804ad41de97fe4cb477c9b2
1 <?xml version="1.0"?>
2 <clause number="17.4.2.2" title="Versioning of constants and static readonly fields">
3   <paragraph>Constants and readonly fields have different binary versioning semantics. When an expression references a constant, the value of the constant is obtained at compile-time, but when an expression references a readonly field, the value of the field is not obtained until run-time. <example>[Example: Consider an application that consists of two separate programs: <code_example><![CDATA[
4 using System;  
5 namespace Program1  
6 {  
7    public class Utils  
8    {  
9       public static readonly int X = 1;  
10    }  
11 }  
12 namespace Program2  
13 {  
14    class Test  
15    {  
16       static void Main() {  
17          Console.WriteLine(Program1.Utils.X);  
18       }  
19    }  
20 }  
21 ]]></code_example></example></paragraph>
22   <paragraph>
23     <example>The Program1 and Program2 namespaces denote two programs that are compiled separately. Because Program1.Utils.X is declared as a static readonly field, the value output by the Console.WriteLine statement is not known at compile-time, but rather is obtained at run-time. Thus, if the value of X is changed and Program1 is recompiled, the Console.WriteLine statement will output the new value even if Program2 isn't recompiled. However, had X been a constant, the value of X would have been obtained at the time Program2 was compiled, and would remain unaffected by changes in Program1 until Program2 is recompiled. end example]</example>
24   </paragraph>
25 </clause>