Does anyone have a very simple example of how to overload the compound assignment operator in C#?
Does anyone have a very simple example of how to overload the compound assignment
Share
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.
You can’t explicitly overload the compound assignment operators. You can however overload the main operator and the compiler expands it.
x += 1is purely syntactic sugar forx = x + 1and the latter is what it will be translated to. If you overload the+operator it will be called.MSDN Operator Overloading Tutorial