title: Using statement and try-catch()-finally repetition?
body: <p>The using(...) statement is syntactic sugar for try{} finally {}.</p>
  
  <p>But if I then have a using statement like below:</p>
  
  <pre><code>using (FileStream fs = File.Open(path))
  {
  
  
  }
  </code></pre>
  
  <p>Now I want to catch the exceptions that opening this file could cause (and this is fairly high risk code in that it can fail due to the environment), but if I write try-catch inside would that not be repetition? When the code gets compiled to IL, I assume the repetition will get deleted when the code is JITted?</p>
  
  <p>However, I would want to catch the exceptions opening a file can cause (so I should wrap the try-catch outside the using statement's scope), and also the exceptions for whatever I do inside the using block so I should add the try-catch inside the block.</p>
  
  <p>This seems like I am adding a lot of repetition to what the CLR probably does inside. Does the CLR add catch clauses?</p>
  
  <p>My colleague argued that a using statement is messy (but this was because a single line was slightly long due to me hard coding them as I needed to change them very quickly and didn't have access to other parts of the code base). Said colleague doesn't use the using statement but is there ever any functional difference between the using statement and try-finally/try-catch-finally? I did see one case of this where WCF services have a not well known corner case about using finally and returning values (something about finally). The solution was to use a check block. Is there anything like this in C#?</p>
  
  <p>On another note, are all types which implement IDisposale owners of unmanaged resources? A discussion with my friend pointed the answer to being no. (I have also read some threads in the using section of this forum, some very good knowledge there).</p>