title: Why Lambda variable scope exists outside LINQ Query?
body: <p>I read this question(<a href="https://stackoverflow.com/questions/10494074/what-is-the-scope-of-a-lambda-variable-in-c">What is the scope of a lambda variable in C#?</a>)</p>
  
  <p>But it is about Lambda variable scope inside LINQ Query.</p>
  
  <p><strong>Now to my question</strong></p>
  
  <p>Lets say I have a very simple LINQ query. </p>
  
  <pre><code>var Foo = FoobBar.Select(x =&gt; x);
  var x = somefunction();
  </code></pre>
  
  <p>Compiler says : <code>A local variable 'x' cannot be declared in this scope because it would give a different meaning to 'x', which is already used in a 'child' scope to denote something else</code>.</p>
  
  <p>Why is that so? Shouldn't Lambda variable cease to exist when LINQ query ends? </p>
  
  <p><strong>EDIT:</strong> After reading answers i came to conclusion that its the outside <code>x</code> (returned from function) whose scope extends inside LINQ Query.</p>