title: Exception inside using initialization
body: <p>I read many threads about the <code>using</code> keyword in C#, but I couldn't find anyone with the same question.
  Reading <a href="http://www.codeproject.com/Articles/6564/Understanding-the-using-statement-in-C" rel="nofollow">this</a> interesting article, it says that the using statement is basically equivalent to a try/catch block:</p>
  
  <pre><code>MyResource myRes= new MyResource();
  try
  {
      myRes.DoSomething();
  }
  finally
  {
      // Check for a null resource.
      if (myRes!= null)
          // Call the object's Dispose method.
          ((IDisposable)myRes).Dispose();
  }
  </code></pre>
  
  <p>What really makes me going mad is that the object initialization <code>myRes= new MyResource()</code> is still outside of the try/catch block, so if something goes wrong during the initialization (oh, and it does!) I have no other way to handle it than using a normal try/catch block.</p>
  
  <p>Is this correct or am I missing something? In my opinion, this makes the sense of the <code>using</code> statement partially useless.</p>
  
  <p>I also tried something like this:</p>
  
  <pre><code>using (MyResource myRes)
  {
      myRes = new MyResource();
      myRes.DoSomething();
  }
  </code></pre>
  
  <p>but the compiler don't like this, so it is not possible to bring the initialization inside of the try block.</p>
  
  <p>This seems so strange to me that I think that I must be missing something. Could anyone explain me the reasons behind this?</p>