'Automatically generating natural Equals and GetHashCode functions for objects
I have found myself overriding the Equals and GetHashCode functions quite often when making classes. It seems like a waste of time since most of the time my Equals is just checking for the equality of every member (or iterating to check equality of IEnumerable elements). Similarly my GetHashCode is usually just the standard list of hash = hash * <prime> + <sub-hash>, possibly iterated.
Is there a library to generate such natural Equals and GetHashCode functions? It seems possible using some of the meta-programming features of C#.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
