title: C# using statement
body: <p>I really want to get this out of my head. Please see below code:</p>
  
  <pre><code>using (DataTable resultTable = DBUtility.GetSingleDBTableResult(connectionString, "SELECT * FROM MyDBTable")) {
      List&lt;string&gt; resultsList = new List&lt;string&gt;();
      foreach (DataRow dataRow in resultTable.Rows) {
          resultsList.Add(dataRow[0].ToString());
      }
      return resultsList;
  }
  </code></pre>
  
  <p>Is the datatable disposed? Can someone explain how this is translated to a try/catch/finally block? MSDN states that if an exception occurred, the Dispose method will still be called but what about the return statement?</p>
  
  <p>Or should i just use below code:</p>
  
  <pre><code>List&lt;string&gt; resultsList = new List&lt;string&gt;();
  using (DataTable resultTable = DBUtility.GetSingleDBTableResult(connectionString, "SELECT * FROM MyDBTable")) {
      foreach (DataRow dataRow in resultTable.Rows) {
          resultsList.Add(dataRow[0].ToString());
      }
  }
  return resultsList;
  </code></pre>
  
  <p>Probably, the second one should be used but I just need enlightenment :). Please explain. Thanks.</p>