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.

Andrew.

Hi,

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.