I am using a HashSet
of List
elements in C#. However, it doesn't get rid of duplicate List
elements.
HashSet<List<int>> set = new HashSet<List<int>>();
List<int> l1 = new List<int>() { 1, 2 };
List<int> l2 = new List<int>() { 1, 2 };
set.Add(l1);
set.Add(l2);
foreach (List<int> l in set) {
foreach(int i in l) {
Console.Write(i + " ");
}
Console.WriteLine();
}
The output is as follows:
1 2
1 2
However, I want the output to be just:
1 2
How do I do that?