How Operators Are Translated
To conclude our discussion about user-defined operators, we take a quick peek at the way their definition gets implemented. As revealed by the static modifier, operators are associated with the type on which they’re defined, rather than with an instance. This has some advantages in terms of compile-time resolution of operators but also limits their expressiveness in terms of runtime dynamism. It’s also not possible to create interfaces that require an implementing type to support certain operators, which is precisely what the mythical
INumeric interface would be about (“can
Multiply, and so on”). This is a bit of an unfortunate implication of the design of operators.
Operators’ operational nature makes their ...