title: using statements
body: <p>Today I noticed a snippet of code that looks like the one below:</p>
  
  <pre><code>public class Test
  {
      SqlConnection connection1 = 
        new SqlConnection(ConfigurationManager.ConnectionStrings["c1"].ToString());
      SqlConnection connection2 = 
        new SqlConnection(ConfigurationManager.ConnectionStrings["c2"].ToString());
  
      public void Method1()
      {
          using (connection1)
          {
              connection1.Open();
              using (SqlCommand newSqlCommand = new SqlCommand("text",connection2))
              {
              // do something       
              }         
          }
      }
  
      public void Method2()
      {
          using (connection1)
          {
              // do something                
          }
      }
  }
  </code></pre>
  
  <p>I am just wondering why would anyone want to open the connection when creating the class and not when calling the corresponding methods inside the class?</p>
  
  <p>EDIT: I should have probably posted the whole code instead. So I do see where they are opening connection1, but then they are instantiating a sqlcommand with a different sql connection (connection2) which has not been opened anywhere. What am I missing here?</p>
  
  <p>Thanks,</p>