I read those articles:
First, second and third that is only for the case for deleting items, but I am not deleting them.
My Code:
Dictionary<String, Object> tempList =(Dictionary<String,Object>)_ersetzeDasMitDas;
//pfadFuerDieBildDatei
foreach (KeyValuePair<string, Object> tempData in tempList)
{
if (tempData.Key.Equals("fahrzeugGruppe"))
{
if (tempData.Value!=null)
{
if (tempData.Value.Equals("LKW"))
{
tempList["pfadFuerDieBildDatei"]= Path.Combine(VirtualMachineKonstanten.statischeDateien, "lkw.png");
}
else if (tempData.Value.Equals("Transporter"))
{
tempList["pfadFuerDieBildDatei"]= Path.Combine(VirtualMachineKonstanten.statischeDateien, "transporter.png");
}
else
{
tempList["pfadFuerDieBildDatei"]= Path.Combine(VirtualMachineKonstanten.statischeDateien, "pkw.png");
}
}
else
{
//todo: logge Error "fahrzeugGruppe", der Wert ist null ?!
//erstmal für Testing
tempList["pfadFuerDieBildDatei"]= Path.Combine(VirtualMachineKonstanten.statischeDateien, "pkw.png");
}
}
}
I get:
Collection was modified; enumeration operation may not execute,
after writing tempList["pfadFuerDieBildDatei"]
and going again to the loop.
How to solve this ?