I want to get pointer to the rectangle from list. But Rectangle is struct and when I try to get pointer I get copy.
Class MyClass
{
Rectangle MovingRectangle;
List<Rectangle> RectangleList;
Point StartLocation;
***some code here***
void PicBoxMouseDown(object sender, MouseEventArgs e)
{
foreach (rectangle in RectangleList)
{
if (condition)
{
MovingRectangle = rectangle;
StartLocation = e.Location;
break;
}
}
}
void PicBoxMouseMove(object sender, MouseEventArgs e)
{
MovingRectangle.Location =
new Point(movingRectangle.Location.X + (e.X - StartLocation.X),
movingRectangle.Location.Y + (e.Y - StartLocation.Y));
}
}
I want to change rectangle position in List, but i change position of copy.