You are trying to make modification to the collection being iterated within the ForEach block. This gives you error.
You can use a while loop or for loop to iterate through the list items.
Check the sample code
Add the listitems out of the foreach block.
foreach ( string item in listBox1.Items)
{
if (listBox2.Items.Contains(item) == false)
{ str += item+"|"; }
else
{ MessageBox.Show("These Stops are already selected!"); }
}
foreach (string s in str.Split('|'))
{
listBox1.Items.Add(s);
}