title: Are there any side effects of returning from inside a using() statement?
body: <p>Returning a method value from <strong>inside</strong> a using statement that gets a DataContext seems to always work <strong>fine</strong>, like this:</p>
  
  <pre><code>public static Transaction GetMostRecentTransaction(int singleId)
  {
      using (var db = new DataClasses1DataContext())
      {
          var transaction = (from t in db.Transactions
                                orderby t.WhenCreated descending
                                where t.Id == singleId
                                select t).SingleOrDefault();
          return transaction;
      }
  }
  </code></pre>
  
  <p>But I always feel like I should be <strong>closing something</strong> before I break out of the using brackets, e.g. by defining transaction <strong>before</strong> the using statement, get it's value <strong>inside</strong> the brackets, and then returning <strong>after</strong> the brackets. </p>
  
  <p><strong>Would defining and returning the variable outside the using brackets be better practice or conserve resources in any way?</strong></p>