title: Order of static constructors/initializers in C#
body: <p>While working on a C# app I just noticed that in several places static initializers have dependencies on each other like this:</p>
  
  <pre><code>static private List&lt;int&gt; a = new List&lt;int&gt;() { 0 };
  static private List&lt;int&gt; b = new List&lt;int&gt;() { a[0] };
  </code></pre>
  
  <p>Without doing anything special that worked. Is that just luck? Does C# have rules to resolve this?</p>
  
  <p><strong>Edit:</strong> (re: Panos) In a file lexical order seems to be king? what about across files?</p>
  
  <p>In looking I tried a cyclical dependency like this:</p>
  
  <pre><code>static private List&lt;int&gt; a = new List&lt;int&gt;() { b[0] };
  static private List&lt;int&gt; b = new List&lt;int&gt;() { a[0] };
  </code></pre>
  
  <p>and the program didn't run the same (the test suit failed across the board and I didn't look further).</p>