Somewhere I came across this good explanation (I will adapt it for this current case):
This is a bad part of C # design.
Inside, things like robot2.Home are implemented as properties, so when you try to assign a value to Home.X , the get-function for Home is called under the hood (and this is where “Cannot change return value ..” comes from). When this is done, you cannot assign the Point structure to a separate member ( X ), but you must assign the entire structure.
So in C # you need to read the value in Point and then change it:
robot2.Home = robot2.Home + new Point (deltaX, deltaY);
Or (if we are not interested in the previous value (as in this case)) simply assign it to a new one:
robot2.Home = new Point (1f, 5f);
PS: Of course, you also need to add a setter for the Home property (as mentioned in other answers).
source share