开发者

C# Operator overloading

开发者 https://www.devze.com 2022-12-12 03:41 出处:网络
Will all .NET languages support operator overloading 开发者_运维问答or C# and managed C++only support it?The Common Language Specification does not enforce any rules in this regard on conforming langu

Will all .NET languages support operator overloading 开发者_运维问答or C# and managed C++ only support it?


The Common Language Specification does not enforce any rules in this regard on conforming languages. They should be able to use overloaded operators in various ways (either the language supports it or you'll do the method call yourself). A language is free to choose whether or not it should provide the ability to declare overloaded operators.


Not all languages will support it but many do. You also need to break the support down into 2 categories

  1. Allowing the language to define overloaded operators
  2. Having the language consume other overloaded operators

VB.Net supports both and I believe IronPython and IronRuby do as well in a dynamic way.

0

精彩评论

暂无评论...
验证码 换一张
取 消