简体   繁体   English

C#运算符重载

[英]C# Operator overloading

所有.NET语言都将支持运算符重载或C#,而托管C ++仅支持它吗?

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. VB.Net两者都支持,我相信IronPython和IronRuby也会以动态方式运行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM