.NET BCL是否具有不可变的Set类型?我正在编写一个C#的功能方言,并希望做类似的事情
new Set.UnionWith(A).UnionWith(B).UnionWith(C)
Run Code Online (Sandbox Code Playgroud)
但我能找到的最好的是HashSet.UnionWith,这将需要以下一系列调用:
HashSet composite = new HashSet();
composite.UnionWith(A);
composite.UnionWith(B);
composite.UnionWith(C);
Run Code Online (Sandbox Code Playgroud)
这种用途高度参考不透明,使其难以优化和理解.如果没有编写自定义功能集类型,有没有更好的方法呢?