title: Compare Objects' properties using hashcode
body: <p>I need to know the ways to compare many objects using hashcode. So here is one of the class.</p>
  
  <pre><code>public class Test: IEquatable&lt;Test&gt;
  {
      public Test()
      {
      }
  
      public string ID { get; set; }
      public string Name{ get; set; }
  
      public static int SafeGetHashCode&lt;T&gt;(this T value) where T : class
      {
          return value == null ? 0 : value.GetHashCode();
      }
  
      public override int GetHashCode()
      {
          int hash = 19;
          hash = hash * 31 + ID.SafeGetHashCode();
          hash = hash * 31 + Name.SafeGetHashCode();
          return hash;
      }
  
      public override bool isSame(object obj)
      {
           // compare objects here
      }
  }
  </code></pre>
  
  <p>But there are 2 errors. Both are same.</p>
  
  <p>'string' does not contain a definition for 'SafeGetHashCode' and no extension method 'SafeGetHashCode' accepting a first argument of type 'string' could be found (are you missing a using directive or an assembly reference?)</p>
  
  <p>And for isSame(), I do not know how to write the code. the concept is compare all the objects and if there are 2 same ID &amp; Name, group them together. </p>
  
  <pre><code>Item A = new Item();
  Item B = new Item();
  Item c = new Item();
  
  A.ID = "Exam1";
  A.Name = "Apple";
  
  B.ID = "Exam1";
  B.Name = "Orange";
  
  C.ID = "Exam1";
  C.Name = "Apple";
  </code></pre>
  
  <p>So Item A and C will group together. </p>