Question: Does the .NET BCL have an immutable Set type? I'm programming in a functional dialect of C# and would like to do something like

```
new Set.UnionWith(A).UnionWith(B).UnionWith(C)

```

But the best I can find is `HashSet.UnionWith`, which would require the following sequence of calls:

```
HashSet composite = new HashSet();
composite.UnionWith(A);
composite.UnionWith(B);
composite.UnionWith(C);

```

This use is highly referentially opaque, making it hard to optimize and understand. Is there a better way to do this without writing a custom functional set type?

Answer: 
The new [ImmutableCollections](https://www.nuget.org/packages/Microsoft.Bcl.Immutable) have:

* `ImmutableStack<T>`
* `ImmutableQueue<T>`
* `ImmutableList<T>`
* `ImmutableHashSet<T>`
* `ImmutableSortedSet<T>`
* `ImmutableDictionary<K, V>`
* `ImmutableSortedDictionary<K, V>`

More info [here](http://blogs.msdn.com/b/bclteam/archive/2012/12/18/preview-of-immutable-collections-released-on-nuget.aspx)

About the union this test passes:

```
[Test]
public void UnionTest()
{
    var a = ImmutableHashSet.Create("A");
    var b = ImmutableHashSet.Create("B");
    var c = ImmutableHashSet.Create("C");
    var d = a.Union(b).Union(c);
    Assert.IsTrue(ImmutableHashSet.Create("A", "B", "C").SetEquals(d));
}

```
There is a [ReadOnlyCollection](http://msdn.microsoft.com/en-us/library/ms132474.aspx), but it's not a hash table. LINQ adds the [Union](http://msdn.microsoft.com/en-us/library/bb341731.aspx) method as an extension.