I got a strange exception when trying to find out if a property in a list of objects is equal for all objects.
This is my code:
bool lvNoGuests = pvBillData.Reservering.Dagen.All(x =>
{
return x.AantalKinderen == pvBillData.Reservering.Dagen[0].AantalKinderen &&
x.AantalVolwassenen == pvBillData.Reservering.Dagen[0].AantalVolwassenen
});
The idea is to use the .All to see if all members of the list have the same value for the two properties as the first entry in the list.
The properties are simple getters (not auto property) and do not modify anything.
When I execute this code, I get an InvalidOperationException "Collection was modified; enumeration operation may not execute".
Anyone got a clue why?
The Lists are not genericht .net lists but are of the type XPCollection (XPO framework of DevExpress).