title: Wrong list count C#
body: <p>I have a list of "price records". If the size of the list is bigger than 0, I want to access the last item of the list. Sometimes my program crashes when it want to access the last item  of the list though the size of the list is 0.</p>
  
  <p>This crash would never occur, in my opinion. Pls help me with your suggestions. </p>
  
  <p>This is my code</p>
  
  <pre><code>JermLib.PriceListFull plNew = DownLoadSymbolHistoricalPrice(yTicker, dirPath, intStartDate, dgwErrorList);
  
  .....
  
  .....
  
  if (plNew.record.Count &gt; (int)0 )
  {
      if (plNew.record.Count &lt; 1 ) { MessageBox.Show("PlNew Count &lt; 1"); }
      else { }
      if (plNew.record.Count == 0) { MessageBox.Show("PlNew Count = 0"); }
      else { }
      // theese test never trigger
  
      // It crashes at:
      if ((  intToday - plMS.record[plMS.record.Count - 1].date &gt;  200 &amp; intToday - plMS.record[plMS.record.Count - 1].date &lt; 1000)
           | intToday - plMS.record[plMS.record.Count - 1].date &gt; 9100  )
  
      //due to 
      //plMS.record.Count - 1 = -1 which is out of bounds
  </code></pre>
  
  <p>}</p>