Is it possible define an extension operator method?

前端 未结 10 733
迷失自我
迷失自我 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:36

    The string class is sealed in C#, so creating a string-derived class actually isn't possible.

    That being said, an extension method will of course work just fine (as will a standard static method in a helper class) but it won't be an operator, just ordinarily-named method.

提交回复
热议问题