why C# not allow operator overloading?

前端 未结 5 1383
醉酒成梦
醉酒成梦 2021-01-17 06:43

why c# not allowed operator overloading while C++ do?

I got this error, when trying to overload.

Overloadable binary operator expected

5条回答
  •  一整个雨季
    2021-01-17 07:36

    It does allow operator overloading..

    that said, it's generally recommended not to override operators since it changes the semantics of your code and therefore makes it less maintainable by others.

提交回复
热议问题