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

定义

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

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

返回

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

注解

source destination如果和重叠destination , 则会将整个的处理方式视为在将其复制到之前将其复制到临时位置。 sourceIf 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.

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

适用于