ImmutableArray<T>.CastUp<TDerived>(ImmutableArray<TDerived>) 方法
定义
基于现有实例的内容,初始化 ImmutableArray<T> 结构的新实例,允许协变静态转换,以便高效重用现有数组。Initializes a new instance of the ImmutableArray<T> struct based on the contents of an existing instance, allowing a covariant static cast to efficiently reuse the existing array.
public:
generic <typename TDerived>
where TDerived : class, T static System::Collections::Immutable::ImmutableArray<T> CastUp(System::Collections::Immutable::ImmutableArray<TDerived> items);
public static System.Collections.Immutable.ImmutableArray<T> CastUp<TDerived> (System.Collections.Immutable.ImmutableArray<TDerived> items) where TDerived : class, T;
public static System.Collections.Immutable.ImmutableArray<T> CastUp<TDerived> (System.Collections.Immutable.ImmutableArray<TDerived>? items) where TDerived : class, T;
static member CastUp : System.Collections.Immutable.ImmutableArray<#'T> -> System.Collections.Immutable.ImmutableArray<'T>
Public Shared Function CastUp(Of TDerived As {Class, T}) (items As ImmutableArray(Of TDerived)) As ImmutableArray(Of T)
类型参数
- TDerived
要返回的数组元素类型。The type of array element to return.
参数
- items
- ImmutableArray<TDerived>
用于初始化该数组的数组。The array to initialize the array with. 不创建任何副本。No copy is made.
返回
其元素已转换为新类型的不可变数组实例。An immutable array instance with elements cast to the new type.
注解
可以通过调用或方法来反转此方法的协变向上转换 As CastArray 。Covariant upcasts from this method may be reversed by calling the As or CastArray method.