DotNext by Roman Sakno

<PackageReference Include="DotNext" Version="2.12.0" />

 IGrowableBuffer<T>

public interface IGrowableBuffer<T> : IDisposable
Represents common interface for growable buffer writers.
long? Capacity { get; }

Gets the maximum number of elements that can hold this buffer.

long WrittenCount { get; }

Gets the number of written elements.

void Clear()

Clears the contents of the writer.

void CopyTo<TArg>(ReadOnlySpanAction<T, TArg> callback, TArg arg)

Passes the contents of this writer to the callback.

int CopyTo(Span<T> output)

Copies the contents of this writer to the specified memory block.

void Write(ReadOnlySpan<T> input)

Writes the memory block.

void Write(T value)

Writes single element to this buffer.