I have used a ListBox in my Windows application. I got the variable iplist
from a WCF server.
After that i addded that list in my ListBox, but it generated an error: "Collections modified, enumuration may not execute".
How might I solve this problem?
My code is:
foreach (ClsPC pc in iclsobj.GetPC())
{
if (listBox1.Items.Count == 0)
{
listBox1.Items.Add(pc.IPAddress);
}
else
{
for (int i = 0; i < listBox1.Items.Count; i++)
{
if (!listBox1.Items[i].ToString().Contains(pc.IPAddress))
{
listBox1.Items.Add(pc.IPAddress);
}
}
}
}