I would like to know if there is a specific reason because of which C# doesn't have automatically generated Equals
, GetHashCode
, and operator ==
, operator !=
geared towards value comparison in reference types.
*Explanation: I do not see an easy way to quickly request "compare actual objects" operation for values/contents of reference types. Coming from C++ background I have impression that it is something that should be done automatically by compiler at simple request of user. The lack of that feature most likely indicates that it might be against language's "design goal"/"vision"/"philosophy". So I would like to know for which reason this functionality was deemed to be unimportant.
--original text--
As far as I can tell, Equals
pretty much amounts to few comparisons to null, attempted cast and field-by-field comparison.
GetHashCode
pretty much amounts to combination of all hashes for members using some operations (multiply with overflow, xor, anything).
As far as I can tell, it should either automated: the methods should be generated by default OR there should be a simple way to request default implementation. However, there is no such thing. Why?
As I understand it, it is either massive technical oversight that persisted for years, or some kind of language philosophy I'm not aware of.
So, what is the reason?