ReadOnlyMemory<T>.ToArray Method

Definition

Copies the contents from the memory region into a new array.

C#
public T[] ToArray();

Returns

T[]

An array.

Remarks

ToArray allocates on the heap and so should generally be avoided. However, it is sometimes necessary to bridge the gap with APIs written in terms of arrays.

Applies to

Produit Versions
.NET Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Standard 2.0 (package-provided), 2.1