Click to See Complete Forum and Search --> : Unusual Compiler Error


Scott MacMaster
March 26th, 2003, 12:11 AM
Does anyone understand this compiler error message?

"Cannot modify the return value of 'expression' because it is not a variable."

It is in reference a line like this:

anObject.AProperty.AnotherProperty = something;

Both properties returns objects not simple data types so it should be returning references not values, right? It it doesn't return references then even something like this, anObject.AProperty = something, won't work. The information about this error message gives an example that resembles numerous lines of code I've written. However, all but this one line of code compiles and works fine.

Well, back to my original question, does anyone understand this error message and know what could cause it?

Thanks

riteshtandon
March 26th, 2003, 12:45 AM
as i understand what is happening is that in the code

anObject.AProperty.AnotherProperty = something;

something is returning a pointer or (anything) that thing is being modified by the object on the left hand side and this cant be done. so the error.

if u could provide the code then it might be more clear whats it.


Ritesh

Scott MacMaster
March 26th, 2003, 01:33 PM
DiagramForm theForm = (DiagramForm)this.MdiChildren[0];
theForm.DiagramScale.Width = theForm.DiagramScale.Width + 10;

public Size DiagramScale
{
get
{
return diagramScale;
}
set
{
diagramScale = value;
}
}


I'm not modifying anything on the left side unless the modification is a implicit behaviour. Anyway, does this code help?


Thanks