title: How to Implement IEquatable<MyType> in a class that
body: <p>I need to have instances of a DispenseFile class that inherits from DispenseEntity that implements IDispenseEntity use a custom equality for purposes of comparing elements in List.</p>
  <p>My interface is:</p>
  <pre><code>public interface IDispenseEntity : IEquatable&lt;IDispenseEntity&gt;
  {
      byte[] Id { get; set; }
      List&lt;byte[]&gt; Key { get; }
      List&lt;byte[]&gt; ParentKey { get; set; }
      double Volume { get; set; }
      public bool DispenseEnabled { get; set; }
      string Name { get; set; }
  }
  </code></pre>
  <p>My DispenseEntity class:</p>
  <pre><code>public class DispenseEntity : IDispenseEntity, IEquatable&lt;IDispenseEntity&gt;
  {
      //Other properties and methods
      
      //I've tried - this implements IEquatable:
      public bool Equals(IDispenseEntity other)
      {
          return Id.SequenceEqual(other.Id);
      }
  
      //I've tried - this overrides default:
      public override bool Equals(object obj)
      {
          return Id.SequenceEqual((obj as IDispenseEntity).Id);
      }
  }
  </code></pre>
  <p>My DispenseFile class:</p>
  <pre><code>public class DispenseFile : DispenseEntity, IParent, IOutputable, IDispenseFile
  {
      //Other methods and properties
      
      public override bool Equals(object obj)
      {
          return base.Equals(obj);
      }
  }
  </code></pre>
  <p>No matter what I use in DispenseEntity class for Equals() method it does not get used when I try:</p>
  <pre><code>List&lt;IDispenseEntity&gt; before = _aList;
  List&lt;IDispenseEntity&gt; after = _bList;
  var intersect = before.Intersect(after).ToList();
  </code></pre>
  <p>The intersect list has zero elements.</p>
  <p>I am absolutely positive that both _aList and _bList have an instance of DispenseFile that inherits DispenseEntity who implements IDispenseEntity. I have written test code that finds the only DispenseFile entity in _aList and finds a single instance of DispenseFile in _bList. Both of these instances are created separately and have identical property Id ( <code>new byte[] {1,2,3,4}</code> )</p>
  <p>I have tried overriding Equals. I have tried adding IEquatable to the base class and implementing the equals and GetHashCode and those don't get used.</p>
  <p>The problem has to be me, what am I doing wrong?</p>