ImmutableArray<T>.Builder.DrainToImmutable Method

Definition

Returns the current contents as an ImmutableArray<T> and sets the collection to a zero length array.

C#
public System.Collections.Immutable.ImmutableArray<T> DrainToImmutable();

Returns

An immutable array.

Remarks

If Capacity equals Count, the internal array will be extracted as an ImmutableArray<T> without copying the contents. Otherwise, the contents will be copied into a new array. The collection will then be set to a zero length array.

Applies to

Product Versions
.NET 8 (package-provided), 8, 9 (package-provided), 9, 10 (package-provided), 10
.NET Standard 2.0 (package-provided)