why c# not allowed operator overloading while C++ do?
I got this error, when trying to overload.
Overloadable binary operator expected
You can overload operators in C#:
Before you decide to use operator overloading, please read at the very least, the following:
EDIT in response to op's edit:
The +=
is a non-overloadable operator. However, it resolves to +
, and +
is overloadable. Have a look here for which operators you can and can not overload.
Operators that can be overloaded:
+
, -
, !
, ~
, ++
, --
, true
, false
+
, -
, *
, /
, %
, &
, |
, ^
, <<
, >>
==
, !=
, <
, >
, <=
, >=
(The comparison operators can be overloaded but see note in link)