Handle Pre/Post-fix increment/decrement operators
Closed this issue · 0 comments
jodavis42 commented
C# defines these operators in an interesting way. When overloading these operators on a class, only one function is created. That function returns the new operator as modified. Under the hood, C# will add extra assignments (sometimes).
So:
++i
is actually
i = operator++(i)
and
a = ++i;
is actually
temp = operator++(i);
a = temp;
i = temp;
Similarly,
a = i++
is actually
temp = operator++(i);
a = i;
i = temp;