I have a List<Buoy>
and I want to remove the Buoy
that is hit by my Ship
.
foreach (var Chest in Chests) {
if (Chest.Bounds.Intersects (Ship.Bounds)) {
Player.Score += 1;
}
}
I have written the Dispose()
-method and I want to set the specific Chest
to null
. How can I do this, without getting the error I am assigning something to Chest
because it is a foreach iteration variable.