title: Avoiding duplicates in a HashSet of custom types in C#
body: <p>I have the following custom class deriving from Tuple:</p>
  
  <pre><code>public class CustomTuple : Tuple&lt;List&lt;string&gt;, DateTime?&gt;
  {
    public CustomTuple(IEnumerable&lt;string&gt; strings, DateTime? time)
        : base(strings.OrderBy(x =&gt; x).ToList(), time)
    {
    }
  }
  </code></pre>
  
  <p>and a <code>HashSet&lt;CustomTuple&gt;</code>.  The problem is that when I add items to the set, they are not recognised as duplicates.  i.e. this outputs 2, but it should output 1:</p>
  
  <pre><code>void Main()
  {
      HashSet&lt;CustomTuple&gt; set = new HashSet&lt;CustomTuple&gt;();
  
      var a = new CustomTuple(new List&lt;string&gt;(), new DateTime?());
      var b = new CustomTuple(new List&lt;string&gt;(), new DateTime?());
  
      set.Add(a);
      set.Add(b);
  
      Console.Write(set.Count); // Outputs 2
  }
  </code></pre>
  
  <p>How can I override the Equals and GetHashCode methods to cause this code to output a set count of 1?</p>