Can I put the GridNode into the HashSet

What I want to do is remove the duplicated GridNode object

it did not overwrite the Equals and GetHashCode methods, but somehow the HashSet will remove the duplicated GraphNode correctly. maybe because Graph.GetNode(x, y) always return the same reference of the GraphNode for the same argument x and y


A GridNode is a class, so it uses pointer equality. It will work just fine to add it to a hash set.