The [System.Collections.Immutable](<https://www.nuget.org/packages/System.Collections.Immutable/>)
NuGet package provides immutable collection classes.
var stack = ImmutableStack.Create<int>();
var stack2 = stack.Push(1); // stack is still empty, stack2 contains 1
var stack3 = stack.Push(2); // stack2 still contains only one, stack3 has 2, 1
Certain immutable collections have a Builder
inner class that can be used to cheaply build large immutable instances:
var builder = ImmutableList.CreateBuilder<int>(); // returns ImmutableList.Builder
builder.Add(1);
builder.Add(2);
var list = builder.ToImmutable();
var numbers = Enumerable.Range(1, 5);
var list = ImmutableList.CreateRange<int>(numbers);
List of all immutable collection types:
[System.Collections.Immutable.ImmutableArray<T>](<https://msdn.microsoft.com/en-us/library/dn638264(v=vs.111).aspx>)
[System.Collections.Immutable.ImmutableDictionary<TKey,TValue>](<https://msdn.microsoft.com/en-us/library/dn467181(v=vs.111).aspx>)
[System.Collections.Immutable.ImmutableHashSet<T>](<https://msdn.microsoft.com/en-us/library/dn467171(v=vs.111).aspx>)
[System.Collections.Immutable.ImmutableList<T>](<https://msdn.microsoft.com/en-us/library/dn456077.aspx>)
[System.Collections.Immutable.ImmutableQueue<T>](<https://msdn.microsoft.com/en-us/library/dn467186(v=vs.111).aspx>)
[System.Collections.Immutable.ImmutableSortedDictionary<TKey,TValue>](<https://msdn.microsoft.com/en-us/library/dn467194(v=vs.111).aspx>)
[System.Collections.Immutable.ImmutableSortedSet<T>](<https://msdn.microsoft.com/en-us/library/dn467193(v=vs.111).aspx>)
[System.Collections.Immutable.ImmutableStack<T>](<https://msdn.microsoft.com/en-us/library/dn467197(v=vs.111).aspx>)