title: Why doesn't hoisting exist in C#?
body: <p>I use both Javascript and C# on a daily basis and I sometimes have to consider hoisting when using Javascript. However, C# doesn't seem to implement hoisting(that I know of) and I can't figure out why. Is it more of a design choice or is it more akin to a security or language constraint that applies to all statically typed languages?</p>
  
  <p>For the record, I'm not saying i WANT it to exist in C#. I just want to understand why it doesn't.</p>
  
  <p><strong>EDIT: I noticed the issue when I declared a variable after a LINQ query, but the LINQ query was deferred until after the variable declaration.</strong></p>
  
  <pre><code>    var results = From c In db.LoanPricingNoFee Where c.LoanTerm == LoanTerm
                     &amp;&amp; c.LoanAdvance &lt;= UpperLimit Select c
                     Order By c.LoanInstalment Ascending;
  
      Int LoanTerm = 12;
  </code></pre>
  
  <p>Throws an error whereas:</p>
  
  <pre><code>    int LoanTerm = 12;
  
      var results = From c In db.LoanPricingNoFee Where c.LoanTerm == LoanTerm
                     &amp;&amp; c.LoanAdvance &lt;= UpperLimit Select c
                     Order By c.LoanInstalment Ascending;
  </code></pre>
  
  <p>Does not.</p>