title: Performance comparison between using block and Dispose method
body: <p>Think about these 2 snippets:</p>
  
  <p><strong>Approach 1: use <code>using</code> statement</strong></p>
  
  <pre><code>using(var connection = new SqlConnection())
  using(var command = new SqlCommand(cmdText, connection)){
      try{
          connection.Open();
          using(var reader = command.ExecuteReader(
              CommandBehavior.CloseConnection | CommandBehavior.SingleResult){
              while(reader.Read())
                  // read values
          }
      } catch (Exception ex) { 
          // log(ex);
      }
  }
  </code></pre>
  
  <p><strong>Approach 2: use <code>try/finally</code></strong></p>
  
  <pre><code>var connection = new SqlConnection();
  var command = new SqlCommand(cmdText, connection);
  SqlDataReader = null;
  try{
      var reader = command.ExecuteReader(
          CommandBehavior.CloseConnection | CommandBehavior.SingleResult);
      while(reader.Read())
          // read values...
  } catch (Exception ex) { 
      // log(ex);
  } finally {
      command.Dispose();
      if (reader != null) {
          if (!reader.IsClosed)
              reader.Close();
          reader.Dispose();
      }
      if (connection.State != ConnectionState.Closed)
          connection.Close();
      connection.Dispose();
  }
  </code></pre>
  
  <p>We all know that the <code>using</code> statements would be compiled to <code>try/finally</code> blocks. So is it correct to say: when the app get compiled, there would be <strong>4</strong> <code>try</code> blocks?</p>
  
  <pre><code>try { // for using SqlConnection
  
      try { // for using SqlCommand
  
          try { // my own try block
  
              try { // for using SqlDataReader
  
              } finally { 
                  // dispose SqlDataReader
              }
  
          } catch { 
              // my own catch. can be used for log etc.
          }
  
      } finally {
          // dispose SqlCommand
      }
  
  } finally {
      // dispose SqlConnection
  }
  </code></pre>
  
  <p>And, if the answer is yes, wouldn't that be a performance issue? Generally, is there any, I mean any performance difference between <code>using</code> blocks and <code>try/finally</code> blocks?</p>
  
  <p><strong>UPDATE:</strong></p>
  
  <p>From comments, I've to say: </p>
  
  <p>1- The important question is, having multiple <code>try</code> blocks inside each other: is there any performance issue?</p>
  
  <p>2- I have to care of code, because I'm responsible to code, not to query. The query-side has its own developer which is doing his best. So, I have to do my best too. So, it's important to me to take care of milliseconds ;) Thanks in advance.</p>