ReadOnlySpan<T>.CastUp<TDerived> 方法

定义

TDerived 的只读范围强制转换为 T的只读范围。

public:
generic <typename TDerived>
 where TDerived : class, T static ReadOnlySpan<T> CastUp(ReadOnlySpan<TDerived> items);
public static ReadOnlySpan<T> CastUp<TDerived> (ReadOnlySpan<TDerived> items) where TDerived : class, T;
static member CastUp : ReadOnlySpan<#'T> -> ReadOnlySpan<'T>
Public Shared Function CastUp(Of TDerived As {Class, T}) (items As ReadOnlySpan(Of TDerived)) As ReadOnlySpan(Of T)

类型参数

TDerived

源只读范围的元素类型,必须派生自 T

参数

items
ReadOnlySpan<TDerived>

源只读范围。 未创建任何副本。

返回

具有转换为新类型的元素的只读范围。

注解

此方法使用协变转换,生成与源共享相同内存的只读范围。 类型约束中表示的关系可确保强制转换是一个安全操作。

适用于