title: Declaring an implicitly typed variable inside conditional scope and using it outside
body: <p>In the simplified code below, </p>
  
  <pre><code>if(city == "New York City")
  {
    var MyObject = from x in MyEFTable
                       where x.CostOfLiving == "VERY HIGH"
                       select x.*;
  
  }
  else
  {
    var MyObject = from x in MyEFTable
                       where x.CostOfLiving == "MODERATE"
                       select x.*;
  
  }
  
    foreach (var item in MyObject)
    {
       Console.WriteLine("&lt;item's details&gt;");
    }
  </code></pre>
  
  <p>The variable MyObject is not accessible outside conditional block. How can I iterate outside the if..else ?</p>