c# - How do you determine if two HashSets are equal (by value, not by reference)? -


I am trying to determine whether two hashets objects in .NET 3.5 ( C #) are the same set, there are similar values ​​in i.e. It seems that something like this is intended to be done clearly, but no work is giving you this information.

The way I can do it, it is checking whether the two sets have the same calculations and one set is another subset of the other (not appropriate) I think That's the only way it can be, if it's the same set example code:

  hashaseet & lt; Int & gt; Set1 = NewHashet & lt; Int & gt; (); Set1.Add (1); Set1.Add (2); Set1.Add (3); HashSet & LT; Integer & gt; Set2 = NewHashet & lt; Int & gt; (); Set2.Add (1); Set2.Add (2); Set2.Add (3); If set (set1 === Set 2.tm and set 1.syssetset (set2)) {// do something}  

will it always work? Is there a better way? Hashless is not function

"text">
  SetEquals ()?  

Comments