title: How do you determine if two HashSets are equal (by value, not by reference)?
body: <p>I am trying to determine if two <code>HashSet</code> objects in .NET 3.5 (C#) are equal sets, <em>i.e.</em> contain the same values. This seems like something one would obviously want to do but none of the provided functions seem to give you this information.</p>
  
  <p>The way I can think to do this is by checking if the count of the two sets are equal <em>and</em> one set is a subset (not proper) of the other. I think the only way that can happen is if they are equal sets. Example code:</p>
  
  <pre><code>HashSet&lt;int&gt; set1 = new HashSet&lt;int&gt;();
  set1.Add(1);
  set1.Add(2);
  set1.Add(3);
  
  HashSet&lt;int&gt; set2 = new HashSet&lt;int&gt;();
  set2.Add(1);
  set2.Add(2);
  set2.Add(3);
  
  if(set1.Count == set2.Count &amp;&amp; set1.IsSubsetOf(set2))
  {
      // do something
  }
  </code></pre>
  
  <p>Would this always work? Is there a better way? Why doesn't <code>HashSet</code> have a  <code>public bool IsEqualSetWith()</code> function?</p>