O'Reilly logo

C# 5.0 Unleashed by Bart De Smet

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Operators

We’re almost at the end of our journey through the world of class and struct members. In the previous chapters, we covered fields, properties, methods, and constructors as the member types you’ll be using on a daily basis.

But we haven’t yet covered what could be the most powerful member type in terms of expressiveness for users of our types. Those are operator overloads. Basically, operator overloads are special static methods that can be invoked as a result of using operator syntax such as +, &&, ==, and so on.

Using this feature, it becomes possible to provide more natural-looking and convenient syntax for various operators a type can support on its instances. Vectors are a great example of this:

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required