title: C# - defining hashset with custom key
body: <p>I am using the <code>HashSet</code> and <code>Dictionary</code> in C# to implement a Graph structure. I have a problem with the uniqueness of <code>HashSet</code> elements when the <code>HashSet</code> key is a customized class. Here I have:</p>
  
  <pre><code>public class Point
  {
      public int x { get; set; }
      public int y { get; set; }
  }
  
  public class Vertex
  {
      public Vertex(Point point)
      {
          VertexLabel = point;
      }
  
      public Point VertexLabel { get; private set; }
  }
  
  public class Edge
  {
      public Edge(Vertex to, Vertex from, double weight)
      {
          FromVertex = from;
          ToVertex = to;
          Weight = weight;
      }
  
      public Vertex FromVertex { get; private set; }
      public Vertex ToVertex { get; private set; }
      public double Weight { get; private set; }
  }
  
  public class Graph
  {
      public Graph()
      {
          _Vertexes = new HashSet&lt;Vertex&gt;();
          _VertexEdgeMapping = new Dictionary&lt;Vertex, LinkedList&lt;Edge&gt;&gt;();
      }
      private HashSet&lt;Vertex&gt; _Vertexes;
      private Dictionary&lt;Vertex, LinkedList&lt;Edge&gt;&gt; _VertexEdgeMapping;
  }
  </code></pre>
  
  <p>The problem is that when I have same vertexes and I want to add them to the graph, they get duplicated. how can I define a way that the <code>HashSet</code> would understand the uniqueness of my vertexes?</p>