ReadOnlySpan<T>.TryCopyTo(Span<T>) Method

Definition

尝试将此 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

Parameters

destination
Span<T>

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

Returns

Boolean

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

Remarks

如果 sourcedestination 重叠,则在将 source 复制到 destination之前,将对整个进行处理,就像它已复制到临时位置。If 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.

Applies to