Any ideas as to why this
public Collection<Point> data = new Collection<Point>(){
new Point{X=10,Y=20},
new Point{X=20,Y=30},
new Point{X=40,Y=20},
new Point{X=10,Y=20}
};
(notice the identical first and last elements) gives the error
An item with the same key has already been added.
If you change the last element to Y=20.1 or anything that makes it different then it works. Also you can add the elements anyway you like and get the same result.
The problem is obviously due to Point being a value type because it goes away if you define and use a point class and I know that there are problems with using structs in other collection types but this has to do with the difference between value and ref return types. What mystifies me is that this works if the all the structs have different field values.