C# get/set/properties question

Started by
21 comments, last by Zahlman 14 years, 2 months ago
Quote:Original post by MaulingMonkey
This is the one that always irks me:

*** Source Snippet Removed ***


Wow, it doesn't translate += for a property into a get/set pair? Epic fail. :(

/me feels increased motivation to target .NET bytecode with that language design...
Advertisement
Quote:Original post by Zahlman
Quote:Original post by MaulingMonkey
This is the one that always irks me:

*** Source Snippet Removed ***


Wow, it doesn't translate += for a property into a get/set pair? Epic fail. :(

/me feels increased motivation to target .NET bytecode with that language design...


No, you missed the point entirely. He's accessing an inner property of the Line. Since Vector2 is a value type, its getter returns a copy, and therefore the access of member X would only update the copied version, not the original. Therefore, C# marks this as an error for you so that you don't get confused as to why the value isn't updating.
Mike Popoloski | Journal | SlimDX
Ahh, I see what you're saying now.

It does kind of suck that 'ref' can apply to parameters but not to the return value. (Of course, 'in' and 'out' would be meaningless for a return value.)

This topic is closed to new replies.

Advertisement