title: Will Dispose() be called in a using statement with a null object?
body: <p>Is it safe to use the <code>using</code> statement on a (potentially) null object?<br>
  Consider the following example:</p>
  
  <pre><code>class Test {
      IDisposable GetObject(string name) {
          // returns null if not found
      }
  
      void DoSomething() {
          using (IDisposable x = GetObject("invalid name")) {
              if (x != null) {
                   // etc...
              }
          }
      }
  }
  </code></pre>
  
  <p>Is it guaranteed that <code>Dispose</code> will be called only if the object is not null, and I will not get a <code>NullReferenceException</code>?</p>