There is probably a quite logical explanation to this, but I have a question.
Let's say I have a variable of type Rectangle called _rect. I can now say _rect.X = 50; without any problems.
Now I have a class with a property called Rect that exposes the internal variable _rect.
Then, if I try to write Rect.X = 50;
I get the following compilation error:
Cannot modify the return value of 'TestClass.Rect' because it is not a variable.
I can write Rect = new Rectangle( 50, Rect.Y, Rect.Width, Rect.Height)
like for a immutable type, but for non-immutable types, are there any other way of doing this?
I want to use auto-properties for this rectangle field, but it's really annoying not being able to modify it inside the class itself.
Are there any way short of making a backing field and dropping the auto-property?