O'Reilly logo

C# 4.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

Implementing Equality Operations

One of the most commonly overloaded operators is == (and its != sister operator). To ensure expected behavior for those operators, a few guidelines exist. In particular, we have to explain the relationship between the operators and the System.Object Equals methods that are available.

The Role of System.Object’s Instance Equals Method

Defined on System.Object, the “mother type of all types”, the Equals instance method is used to compare whether two objects are “equal,” whatever that means for the types of the target object and the one being compared.

image

As you learn in Chapter 14, “Object-Oriented Programming,” virtual ...

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