title: Safely remove list from list in loop
body: <p>I am iterating through all the list in mainlist and if a specific condition occur. I want to remove that specific list.</p>
  
  <p>It is not working.</p>
  
  <pre><code>for (int i = 0; i &lt; mainList.Count; i++)
  {
       if (mainList[i].Dead == true) //
       {
            mainList.removeAt(i);//what will be affect on mainList.Count;
       }
   }
  </code></pre>