Arild Fines <[EMAIL PROTECTED]> wrote: > >FWIW - I think Petzold misunderstood/misrepresented something > > there. His example was referring to someControl.Size.Width * 2; > > something which will fail because the Size property will return a > > copy of the Size struct. > > > > Making changes to the Width property of the returned struct will > > have no effect onthe original and the whole statement is pointless. > > The compiler recognizes this and issues a warning(or an error - > > dont remember offhand).
From: "Jon Jagger" <[EMAIL PROTECTED]> > But the whole statement might _not_ be pointless. One of the > main points of a property is that a write context you don't get > an assignment you get a set accessor. Ah, but this isn't a write context. At least it's not for the Size property. This causes a *get* of the Size. It might then perform a set on the size struct's Width, but it'll be a copy of the Size that it performs the set on. And unless the Size were to hold a reference back to its containing object (which would pretty much defeat the purpose of making it a value type in the first place) then there's nothing useful that the Size.Width set accessor can do anyway. -- Ian Griffiths DevelopMentor You can read messages from the DOTNET archive, unsubscribe from DOTNET, or subscribe to other DevelopMentor lists at http://discuss.develop.com.