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! While you're at it, check out some resources Treehouse students have shared here.

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

C# Intermediate C# System.Object Object.GetHashCode

Damir Paulić
Damir Paulić
6,591 Points

So, if we altered 2 objects to have same hash code what happens if we change value of one of this objects?

To summarize it like this:

We gave 2 different objects same pointer to memory space.

Both of them now addresses the same space.

If we change one of the object value does it change in the same space and automatically change value of second object || OR || does it get new hash code to another memory space and leaves 2nd object intact?

1 Answer

Steven Parker
Steven Parker
231,269 Points

If you have two pointers to the same memory space, you only have one object, not two. You just have two ways to reference it.

So if you then change any property of the object (like the hash code), the change will be seen when referencing it from either pointer.