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

定义

尝试将当前 Span<T> 复制到目标 Span<T>,并返回一个指示复制操作是否成功的值。Attempts to copy the current Span<T> to a destination Span<T> and returns a value that indicates whether the copy 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 source和重叠destination ,destination此方法也会将全部复制到。This method copies all of source to destination even if source and destination overlap.

如果destination比源Span<T>短, 则此方法将返回false, 并且不写入destination任何数据。If destination is shorter than the source Span<T>, this method returns false, and no data is written to destination.

适用于