static field Initialization in debug and release build
<p>I found static field initialization can behave differently. for the following code,        </p>

<pre class="lang-cs prettyprint-override"><code>public class Class1
{
  public static void Main()
  {
    Console.WriteLine("Main");
    Test();
    Console.ReadLine();
  }

  public static void Test(){
    Console.WriteLine("Test");
    Singleton.Instance.DoSomething();
  }
}

public class Singleton
{
  private static Singleton sInstance = new Singleton();

  protected Singleton()
  {
    Console.WriteLine("Singleton Constructor");
  }

  public static Singleton Instance
  {
    get
    {
      return sInstance;
    }
  }

  public void DoSomething(){}
}
</code></pre>

<p>in the debug build, it will print</p>

<pre><code>Main
Test
Singleton Constructor
</code></pre>

<p>while in release build, it will print </p>

<pre><code>Main
Singleton Constructor
Test
</code></pre>

<p>I checked the IL code generated of these 2 builds, there are nearly the same.
<p>I wonder how this happens? And if it is a kind of JIT optimization in the release build, what is the motivation? </p>
