Is it possible define an extension operator method?

前端 未结 10 732
迷失自我
迷失自我 2021-01-04 02:09

is it possible to define an extension method that at the same time is an operator? I want for a fixed class add the possibility to use a known operator that actually can\'t

10条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-01-04 02:50

    No, it is not possible to do from outside of the class. ++ operator should be defined inside class which is being incremented. You can either create your own class which will be convertible from string and will have ++ overload or you can forget about this idea and use regular methods.

提交回复
热议问题