Operator Overloading

Operator overloading creates operator behavior for user-defined types. The best-known example of operator overloading is in C++. The >> and << operators, which are normally the bitwise shift operators, are overloaded to support input and output streams. The >>operator becomes the extraction operator, while the << operator becomes the insertion operator. You can overload operators for any user-defined types in C# to make those types functionally similar to standard or primitive types. However, when overloading operators you should adhere to the general meaning of the operator. For example, don’t overload an operator + for a user-defined type to perform some type of subtraction or deletion. That would definitely confuse users. ...

Get Programming Microsoft® Visual C#® 2008: The Language now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.