I am trying to come up with a way to override GetHashCode () when called from Vector2 []. This code creates unique hashes for objects that I know are equal: I pass the next class to the same rectangle, and different hashes are generated.
public Shape(Rectangle r) { edges = new Vector2[4]; edges[0] = new Vector2(0, 0); edges[1] = new Vector2(r.Width, 0); edges[2] = new Vector2(r.Width, r.Height); edges[3] = new Vector2(0, r.Height); Console.Write(edges.GetHashCode() + "\n"); Position = new Vector2(rX, rY); }
The Vector2 array is just a collection of int functions. How to create a unique hash for an ints list?
Max kessler
source share