Operator Overloading

Operator overloading allows operators to be defined on a class or struct so that it can be used with operator syntax. This is most useful on data types where there is a good definition for what a specific operator means, thereby allowing an economy of expression for the user.

Overloading the relational operators (==, !=, >, <, >=, <=) is covered in the section of Chapter 32 that explains how to overload the Equals() function from the .NET Framework.

Overloading conversion operators is covered in Chapter 25.

Unary Operators

All unary operators are defined as static functions that take a single operator of the class ...

Get A Programmer's Guide to C# 5.0, 4th Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.