views:

55

answers:

1

The C# compiler doesn't allow this. What's the reason for this? And what workaround I can use?

Basically I need to swap some values around, but don't wanna have the same swapping code all over.

+5  A: 

Properties, in general are just methods, so it would be strange if you could just "get reference to them", as no one can be sure, that you are referring to just a variable. I don't think there's a quick and nice workaround other that not using auto-properties in this case.

I'm omitting the idea of using reflection to get to those variables under the hood, as it wouldn't make much sense in this case.

Ravadre