title: Visual Studio Variable Not Created When Manually Setting Next Statement
body: <p>I just started using a new Windows 7 x64 machine today and experienced something new during debugging. I have code that can be thought of as the following:</p>
  
  <pre><code>if(/*Some criteria that evaluates to false*/)
  {
      int weekNum = (int)DateTime.Now.Subtract(_myObject.StartDate).TotalDays/7;
  
      //Do something with weekNum
  }
  </code></pre>
  
  <p>I wanted to debug through the code within the if block. In my current circumstances, it's much easier just to set the next statement to the first line inside the block than to make my data meet the criteria so I set the next execution line to int weekNum... This gives a null reference exception because it, apparently, is not instantiating weekNum. I've verified that nothing on the right side expression is null and can successfully get a result by copying and pasting the right side into the watch or immediate window. If I literally replace it with if(true), it works fine. Choosing the next execution statement in scenarios like this has been a pretty routine way of debugging for me. Why is it behaving this way?</p>
  
  <p>Edit: I have verified that the current build configuration is not optimized.</p>
  
  <p>Edit: I cannot reproduce this in another test project. I modified my original code to remove my object from the equation and here is the new full code that gets the exception in the original project:</p>
  
  <pre><code>    private void SelectDefaultLearningUnit()
      {
          TODLogic.LearningUnit currentLu = null;
  
          //If sce is active get the learning unit for the current week.
          if (!_sce.IsCancelled &amp;&amp; !_sce.IsCancelled
              &amp;&amp; _sce.StartDate &lt;= DateTime.Now
              &amp;&amp; _sce.EndDate &gt; DateTime.Now)
          {
              //Get number of weeks since semester started
              int currentWeek = (int)4;    //THIS LINE STILL BLOWS UP
  
              //Find the first learning unit for the current week
              currentLu = _LearningUnits.Where(lu =&gt; lu.StartWeek &lt;= currentWeek &amp;&amp; lu.EndWeek &gt;= currentWeek).FirstOrDefault();  //May be null
          }
  
          if (currentLu == null)
              currentLu = _LearningUnits.FirstOrDefault();
  
          cbLearningUnit.SelectedItem = currentLu;
      }
  </code></pre>
  
  <p>Again, it only gets the exception if I manually set the execution inside of the if block when it would've otherwise been skipped. The only difference I see is if I put a watch on the variable in the test project it says the value of currentWeek is 0 until it hits the line and then it gets assigned. In the project where it blows up, it shows a red excalamation mark to the left of current week and the value says '' is null. I would expect it to either say the value is 0 or 'currentWeek' is undefined! This is why I originally thought it thought currentWeek was "not instantiated" i.e. didn't exist.</p>