InvalidOperationException after removing an element in an arrayList
<p>Hi I am trying to remove all numbers that are divisible by two from the arrayList.The probleme is that after one element is removed I get an InvalidOperationException.</p>

<pre><code>   private ArrayList RemoveDivTwo(ArrayList list) {
        int count = 0;
        foreach(int i in list){
            if ((i &gt; 2) &amp;&amp; (i % 2 == 0)) {
                list.RemoveAt(count); 
            }
            count++;
        }

        return list;
    }
</code></pre>

<p>How can I solve this problem so I wont't get an exception and be able to remove all elements divisible by two?</p>
