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.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
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.