Memory<T>.ToArray Memory<T>.ToArray Memory<T>.ToArray Memory<T>.ToArray Method

定义

将此内存的内容复制到新数组中。Copies the contents from the memory into a new array.

public:
 cli::array <T> ^ ToArray();
public T[] ToArray ();
member this.ToArray : unit -> 'T[]
Public Function ToArray () As T()

返回

T[]

包含当前内存中元素的数组。An array containing the elements in the current memory.

注解

由于对 < xref=System.Memory%601.ToArray%2A > 方法的调用中执行堆分配,它通常应当避免。Because a call to the <xref=System.Memory%601.ToArray%2A> method performs a heap allocation, it should generally be avoided. 但是,它,有时需要利用的功能仅适用于数组的功能。However, it is sometimes necessary to take advantage of functionality that is only available for arrays.

每次调用ToArray方法返回一个新数组。Each call to the ToArray method returns a new array.

适用于