title: C# anonymous objects in "using" statements reliable?
body: <p>Imagine this snippet:</p>
  
  <pre><code>using System;
  
  
  
  public class Report {
      static int Level=0;
  
      public static void WriteLine(string Message) {
          Console.WriteLine("{0}{1}",new String(' ',4*Level),Message);
      }
  
      public class Indent:IDisposable {
          public Indent()            { Report.WriteLine("{"); ++Level; }
          void IDisposable.Dispose() { --Level; Report.WriteLine("}"); }
      }
  }
  
  
  
  class Program {
      static void Main() {
          Report.WriteLine("Started");
          Report.WriteLine("Calling submethod");
          using(new Report.Indent()) {
              Report.WriteLine("Submethod started");
              using(new Report.Indent()) Report.WriteLine("Subsub, maybe?");
              Report.WriteLine("Submethod reporting everything is fine");
              Report.WriteLine("Submethod finished");
          }
          Report.WriteLine("Finished");
      }
  }
  </code></pre>
  
  <p>Which produces result:</p>
  
  <pre><code>Started
  Calling submethod
  {
      Submethod started
      {
          Subsub, maybe?
      }
      Submethod reporting everything is fine
      Submethod finished
  }
  Finished
  </code></pre>
  
  <p>Inside I'm using <code>using(new Report.Indent())</code> instead of sticking to the only documented version I found, i.e. <code>using(Report.Indent r=new Report.Indent())</code>.</p>
  
  <p>In my briefer version, however, can I be sure that <code>Dispose()</code> will always be called on those unnamed Indent objects, every time?</p>
  
  <h3>P.S.</h3>
  
  <pre><code>// btw, I used word "anonymous" in the title, but I'm not sure that's what new objects that aren't assigned to any named variable should be called
  </code></pre>