title: Parts of a nested if statement not being reached
body: <p>I'm at a bit of a loss as to why the <code>highestOrderLowestTradeVersion</code> lines in this if-statement below are not being hit; when debugging, the aforementioned variable never exists in the if-statement context. Even if the final two if-statements below are true, it simply ignores the <code>highestOrderLowestTradeVersion</code> lines. I've tried moving the variable declaration higher in the list, not initialising it, and initialising it separately after declaring it, but I still can't get a value for that variable. Is there anything obviously wrong in my code below? </p>
  
  <pre><code>int latestOrderVersion;
  int latestTradeVersion;
  
  int lowestOrderVersion = 0;
  int lowestOrderHighestTradeVersion = 0;
  
  int highestOrderVersion = 0;
  int highestOrderHighestTradeVersion = 0;
  int highestOrderLowestTradeVersion = 0;
  
  foreach (DataRow filterResult2 in filterResults2.Rows)
  {
      latestOrderVersion = Convert.ToInt32(filterResult2["OrderVersion"]);
      latestTradeVersion = Convert.ToInt32(filterResult2["TradeVersion"]);
  
      if (lowestOrderVersion == 0 || latestOrderVersion &lt; lowestOrderVersion)
      {
          lowestOrderVersion = latestOrderVersion;
  
          if (lowestOrderHighestTradeVersion == 0 || lowestOrderHighestTradeVersion &lt; latestTradeVersion)
          {
              lowestOrderHighestTradeVersion = latestTradeVersion;
          }
      }
  
  
      if (highestOrderVersion == 0 || latestOrderVersion &gt; highestOrderVersion || latestOrderVersion == highestOrderVersion)
      {
          if (latestOrderVersion != highestOrderVersion)
          {
              highestOrderVersion = latestOrderVersion;
              highestOrderLowestTradeVersion = 0;    // never gets hit
          }
  
          if (highestOrderHighestTradeVersion == 0 || latestTradeVersion &lt; highestOrderHighestTradeVersion)
          {
              highestOrderLowestTradeVersion = latestTradeVersion;    // never gets hit
          }
      }
  }
  </code></pre>