Until we have record types in C# we’ll have to use classes or structs for our Value objects. What makes this annoying is that we have to override the Equals and GetHashCode methods to get correct equality checks.
Until I stumbled over the following blog post by James Montemagno: https://montemagno.com/optimizing-c-struct-equality-with-iequatable/. In this post he explains how we can use ValueTuples in combination with the new tuple syntax to get cleaner Equals and GetHashCode checks.
Here is the code before:
Here is the code after introducing ValueTuples: