ShareThis

Friday, June 29, 2012

[C#] How to compare two HashSets

Example Data:


HashSet<int> set1 = new HashSet<int>();
set1.Add(1);
set1.Add(2);
set1.Add(3);
HashSet<int> set2 = new HashSet<int>();
set2.Add(1);
set2.Add(2);
set2.Add(3);



How you can compare one against the other:

if(set1.SetEquals(set2)){...}

0 comments:

Post a Comment