C# 如何创建一组集合

dmj*_*und 3 c# set

我想创建一组(int 的)集合

就像是:

SortedSet<SortedSet<int>>
Run Code Online (Sandbox Code Playgroud)

或者

HashSet<HashSet<int>>
Run Code Online (Sandbox Code Playgroud)

但是当尝试匹配集合时,它使用 ReferenceEquals 进行比较

因此对我的目的来说毫无用处

有没有办法让一组集合在 C# 中有用?

SLa*_*aks 5

您需要传递HashSet<int>.CreateSetComparer()到外部集合以通过引用进行比较。