Memory<T>.ToArray 方法

定义

将此内存的内容复制到新数组中。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.

注解

因为对方法的调用 ToArray 会执行堆分配,所以通常应避免这样做。Because a call to the ToArray 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.

适用于