title: How to create a unique hash for my class to use as a dictionary key
body: <p>I am really confused how to use my class for a key in a dictionary.</p>
  <p>I need to store key value pairs of my node class so i know what path i have traversed on my double connected graph.</p>
  <p>So i need to create a unique hash for my class to use the node as a key. But i have no idea what i am meant to do to implement it.</p>
  <p>My node class is a simple one:</p>
  <pre><code>  public class Node
    {
          public Vector2 Position;
          public List&lt;Node&gt; Connections;
    }
  </code></pre>
  <p>And in my graph traversal script I need to use a dictionary like this:</p>
  <pre><code>    //store paths &quot;From&quot;=&gt; key, &quot;To&quot;=&gt; value
      Dictionary&lt;Node, Node&gt; _visitedPaths;
  </code></pre>
  <p>On the Microsoft website it says:</p>
  <blockquote>
  <p><em>Two objects that are equal return hash codes that are equal. However, the reverse is not true: <strong>equal hash codes do not imply object
  equality, because different (unequal) objects can have identical hash
  codes.</strong></em></p>
  </blockquote>
  <p>So if my understanding on this is correct, two different objects can create identical hash codes, so I need to implement my own hash code but I am not sure how I can guarantee to generate a unique hash code for each node object.</p>