ReadOnlySpan<T>.TryCopyTo(Span<T>) 方法

定义

尝试将此 ReadOnlySpan<T> 的内容复制到 Span<T> 中,并返回一个值以指示操作是否成功。Attempts to copy the contents of this ReadOnlySpan<T> into a Span<T> and returns a value to indicate whether or not the operation succeeded.

public:
 bool TryCopyTo(Span<T> destination);
public bool TryCopyTo (Span<T> destination);
member this.TryCopyTo : Span<'T> -> bool
Public Function TryCopyTo (destination As Span(Of T)) As Boolean

参数

destination
Span<T>

复制操作的目标。The target of the copy operation.

返回

Boolean

如果复制操作已成功,则为 true;否则,为 falsetrue if the copy operation succeeded; otherwise, false.

注解

如果 sourcedestination 重叠,则会将整个的 source 处理方式视为在将其复制到之前将其复制到临时位置 destinationIf the source and destination overlap, the entirety of source is handled as if it was copied to a temporary location before it is copied to destination.

如果 destination 长度短于,则 source 不会复制任何项,并且方法将返回 falseIf the destination length is shorter than source, no items are copied and the method returns false.

适用于