Hi, not sure if the title is correct but I think that's what I mean.

I have the following code:

//Box the shape is contained in
        protected Rectangle container;

        /// <summary>
        /// Gets or sets the value for position
        /// </summary>
        public Point Position
            get { return container.Location; }
            set { container.Location = value; }

And then later in a derived class I have the function

public override void move(Point destination)
            Position.X += destination.X;
            Position.Y += destination.Y;

When I compile this it says Error 1 Cannot modify the return value of 'TextVisualiser.Drawing.basicShapes.Position' because it is not a variable . What does this mean? Do I have to have a variable with the same name as the property?

Thanks for any and all help.



Do you override any thing about the definition of property called Position ? If not then your problem is you try to use += variable on a value type member of position but position it self is neither value, nor reference type it is just a property with accessor functions defined. Try that instead :

public override void move(Point destination)
    Point p = Position;
    p.X += destination.X;
    p.Y += destination.Y;

Loren Soth

This question has already been answered. Start a new discussion instead.