Struct's via Automatic Properties can be tricky

Here's a bit of code i just got through debugging...

public Point Point { get; private set; }

public void Offset(Point origin)
  Point.Offset(-origin.X, -origin.Y);

Can you tell what's wrong here? Let's just say that the Offset won't take.

structs are value types, which means anytime you pass one around you get a new copy. So far so good. And that means when you expose a struct value via a property, the accessing party always is looking at a copy. Again, fine, after all when you do a set you change the stored value and if you need to manipulate it, you just manipulate the actual struct.

Enter Automatic properties and you might forget about this last detail and not realize that you never get access to the underlying value, even from within the class. I.e. when I call Point.Offset, i'm calling it on the copy that was passed to me and the resulting value is immediately thrown away. So i just went back to using the property to facade a private Point, which i can now manipulate inside of Offset. Duh.