A Python developer doing some C# (.NET 4.6, Visual Studio 2015 Professional) work here. I am trying to check whether two HashSet
s are equal.
I have two HashSet<List<float>>
which I am trying to compare using
thisList.SetEquals(otherList);
However, this returns false
on my data. Using the sample from the MSDN HashSet
's examples does work as expected. However, in the samples they use HashSet<int>
whereas I use HashSet<List<float>>
.
As I could not found a way to print the HashSet
contents into Immediate Window in Visual Studio (ToString
returns "System.Collections.Generic.HashSet1[System.Collections.Generic.List1[System.Single]]"
), I use Json.NET JsonConvert.SerializeObject(thisList);
to dump the data into a .json
file on disk.
Two files (each for each HashSet
contents is:
[[10.0,15.0],[20.0,25.0]]
and [[10.0,15.0],[20.0,25.0]]
Inspecting the HashSet
s in Visual Studio while debugging looks like this:
- thisList Count = 2 System.Collections.Generic.HashSet<System.Collections.Generic.List<float>>
- [0] Count = 2 System.Collections.Generic.List<float>
[0] 10 float
[1] 15 float
+ Raw View
- [1] Count = 2 System.Collections.Generic.List<float>
[0] 20 float
[1] 25 float
+ Raw View
+ Raw View
- otherList Count = 2 System.Collections.Generic.HashSet<System.Collections.Generic.List<float>>
- [0] Count = 2 System.Collections.Generic.List<float>
[0] 20 float
[1] 25 float
+ Raw View
- [1] Count = 2 System.Collections.Generic.List<float>
[0] 10 float
[1] 15 float
+ Raw View
+ Raw View
Each HashSet
contains two lists (order is not of relevance, since it is a set) and each list has identical values (with the same order). They should be considered equal.
What should I do to make these HashSet
s to be considered equal with thisList.SetEquals(otherList);
?
EDIT:
Printing coord.ToString("G17")
on each float:
10
15
20
25
20
25
10
15