title: Using GetHashCode to test equality in Equals override
body: <p>Is it ok to call GetHashCode as a method to test equality from inside the Equals override?</p>
  
  <p>For example, is this code acceptable?  </p>
  
  <pre><code>public class Class1
  {
    public string A
    {
      get;
      set;
    }
  
    public string B
    {
      get;
      set;
    }
  
    public override bool Equals(object obj)
    {
      Class1 other = obj as Class1;
      return other != null &amp;&amp; other.GetHashCode() == this.GetHashCode();
    }
  
    public override int GetHashCode()
    {
      int result = 0;
      result = (result ^ 397) ^ (A == null ? 0 : A.GetHashCode());
      result = (result ^ 397) ^ (B == null ? 0 : B.GetHashCode());
      return result;
    }
  }
  </code></pre>