C# Won't allow me to do this.
foreach (Point point in filledPoints)
{
point.X = 0;
}
filledPoints is a List<Point>
It gives me a compiler error: "filledPoints is a foreach iteration variable, so the associated members can't be edited" (Sorry, the message is in german and im bad at translating). But this works:
foreach (Point point in filledPoints)
{
Point point2 = point;
point2.X = point2.X / oldSize.Width * Size.Width;
}
Why does this not work and is there a more elegant way to bypass it?
That it doesn't workalso what line does it throw the error on..? do you know how to use the debugger..? if so set breakpoints and tell us the valid error" it doesn't work"as an error message.foreach(which you are not allowed to do). Normally with reference types its ok to modify properties butPointis not a reference type, its astruct. So when you are trying to modify a property, you are actually modifying the entire thing.