title: C# BeforeFieldInit Jon Skeet explanation confusion
body: <p>I read through Jon Skeet's <a href="http://csharpindepth.com/Articles/General/BeforeFieldInit.aspx" rel="noreferrer">article</a> about <code>beforefieldinit</code> and I stumbled upon a question. He mentions that the type initializer can be invoked at any time before the first reference to a static field is called.</p>
  
  <p>This is <em>my</em> test code:</p>
  
  <pre><code>class Test1
  {
      public static string x1 = EchoAndReturn1("Init x1");
  
      public static string EchoAndReturn1(string s)
      {
          Console.WriteLine(s);
          return s;
      }
  }
  
  class Programm
  {
      public static void Main()
      {
          Console.WriteLine("Starting Main");
  
          Test1.EchoAndReturn1("Echo 1");
  
          Console.WriteLine("After echo");
  
          string y = Test1.x1;  //marked line
      }
  }
  </code></pre>
  
  <p>The output is:</p>
  
  <pre><code>Init x1
  Starting Main
  Echo 1
  After echo
  </code></pre>
  
  <p>But without the <em>marked line</em>, so without the invocation of the static field <code>x1</code>, the output is:</p>
  
  <pre><code>Starting Main
  Init x1
  Echo 1
  After echo
  </code></pre>
  
  <p>So the invocation of <em>objects</em> that are flagged with <code>beforefieldinit</code> affects the invocation of their type initializers? Or does this belong to the strange effect of <code>beforefieldinit</code> he mentioned?</p>
  
  <blockquote>
    <p>So, beforefieldinit can make the invocation of the type initializer even lazier or more eager.</p>
  </blockquote>