Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community!
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.Start your free trial
Mark Blanford427 Points
If the hashcode is the memory address by default how can it also possibly *not* be unique?
Why would GetHashCode() need to be overridden under normal circumstances if by default it returns the memory address? Two different objects can't have the same memory address, so is it not inherently unique? Or is this in case a different object has had its GetHashCode method altered so that it happens to return something that looks identical to an existing memory address (but is in fact just an integer and a coincidence)? This is very confusing!
Steven Parker225,728 Points
The issue is that you don't want the hash code to always be unique. In particular, if two things are equal then they must return the same value for
So when you change how things are determined to be equal, you're expected to also change the hash method so equal items will return the same thing.