asifakhtar
03-01-2009, 08:13 PM
How can I remove 2 or more items from a Dictionary<string, string>. With my code I am getting the following error:
“Collection was modified; enumeration operation may not execute.”
Here is my coding:
foreach (KeyValuePair<string, string> pair in tmpList)
{
if (pair.Value == "a" || pair.Value == "b")
{
tmpList.Remove(pair.Key);
}
}
“Collection was modified; enumeration operation may not execute.”
Here is my coding:
foreach (KeyValuePair<string, string> pair in tmpList)
{
if (pair.Value == "a" || pair.Value == "b")
{
tmpList.Remove(pair.Key);
}
}