Subclass HashSet so that it always uses a certain IEqualityComparer when used in another set
- 阅读更多 关于 Subclass HashSet so that it always uses a certain IEqualityComparer when used in another set
问题 I want to subclass HashSet<Point> so that it uses HashSet<Point>.CreateSetComparer() as an IEqualityComparer whenever I use it inside another set. Basically every time I do this: var myDict = new Dictionary<MySubclassOfHashSet, Char>(); I want it automatically treated as : var myDict = new Dictionary<HashSet<Point>, Char>(HashSet<Point>.CreateSetComparer()); As per this question. I have currently done this manually as follows: class MySubclassOfHashSet: HashSet<Point> { public override bool