This is because Point
is a value type (struct
).
Because of this, when you access the Origin
property you're accessing a copy of the value held by the class, not the value itself as you would with a reference type (class
), so if you set the X
property on it then you're setting the property on the copy and then discarding it, leaving the original value unchanged. This probably isn't what you intended, which is why the compiler is warning you about it.
If you want to change just the X
value, you need to do something like this:
Origin = new Point(10, Origin.Y);
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…