Span<T>.ToArray 方法

定义

将此范围的内容复制到新数组中。Copies the contents of this span 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 data in the current span.

注解

此方法执行堆分配,因此应尽可能避免使用。This method performs a heap allocation and therefore should be avoided if possible. 有时,当支持 Span<T> 对象的 Api 不可用,但使用数组的 Api 是必需的。It it sometimes necessary when APIs that support Span<T> objects are not available but APIs that work with arrays are.

适用于