Why is Equality important in .NET?
You can get by without consideration of equality in .NET projects for quite some time without having too many problems. Eventually, however, the time comes when you have to dig into those odd problems and fix things properly.
Types of Equality
Having established the importance of equality in .NET, we can look at the different kinds of equality that you might encounter. There are three - Reference, Value and Entity equality.
Equality has Symmetry
If we’re going to implement equality correctly, we need to consider the contract we’re implementing - what are the characteristics of a proper implementation of equality? The first characteristic we need to consider is symmetry.
Equality and GetHashCode
After symmetry, another aspect of the equality contract is .GetHashCode(). When you first override .Equals(object), the C# compiler will helpfully remind you that you must also override .GetHashCode().
Sharpen The Saw #31
In this issue from September 2017: Techniques for your next public speech; creating great slides; Fira Code should be your next coding font; Rob Connery opines on diversity; Jon Skeet also has diversity requirements; fix a Git vulnerability; Update Visual Studio 2017 now; 10 presentation antipatterns; and how to get started with public speaking.
Implementing Entity Equality
Now that we’ve talked about the importance of implementing equality, the different kinds of equality, and about the contracts required of our implementations, we can get down to actually writing some code.
Earlier
« February 2018
Later
April 2018 »