title: Checking equality with a HashSet of objects
body: <p>I am trying to compare two hashsets of <code>Definition</code> type as <code>EqualityComparer&lt;T&gt;.Default.Equals(value, oldValue)</code>. <code>Definition</code> is defined as follows</p>
  
  <pre><code>public class Definition
  {
      public string Variable { get; set; }
      public HashSet&lt;Location&gt; LocationList { get; set; }
  
      public override bool Equals(object obj)
      {
          Definition other = obj as Definition;
          return other.Variable.Equals(this.Variable) &amp;&amp; other.LocationList!= null &amp;&amp;this.LocationList != null
              &amp;&amp; other.LocationList.Count == this.LocationList.Count
              &amp;&amp; other.LocationList == this.LocationList;
      }
  
      public override int GetHashCode()
      {
          return this.Variable.GetHashCode() ^ this.LocationList.Count.GetHashCode();// ^ this.LocationList.GetHashCode();
      }
  }
  
  public class Location
  {
      public int Line { get; set; }
      public int Column { get; set; }
      public int Position { get; set; }
      public string CodeTab { get; set; }
      public Location(int line, int col, int pos, string tab)
      {
          Line = line;
          Column = col;
          Position = pos;
          CodeTab = tab;
      }
      public override bool Equals(object obj)
      {
          Location other = obj as Location;
          return this.CodeTab == other.CodeTab
              &amp;&amp; this.Position == other.Position
              &amp;&amp; this.Column == other.Column
              &amp;&amp; this.Line == other.Line;
      }
      public override int GetHashCode()
      {
          return this.CodeTab.GetHashCode() ^ this.Position.GetHashCode() 
              ^ this.Column.GetHashCode() ^ this.Line.GetHashCode();
      }
  }
  </code></pre>
  
  <p>Somehow for a similar set, the result is returned as <code>false</code> despite all the information remaining the same. The only difference is that the position of some elements are interchanged, but I know that <code>HashSet</code> won't preserve or check the order while comparing. Can any one advise me on what is going wrong here?</p>
  
  <p>PS: I tried uncommenting <code>this.LocationList.GetHashCode()</code> also, but didn't work.</p>