ImmutableArray<T>.As<TOther> 方法

定义

返回一个新的不可变数组,其中包含此数组的元素转换为其他类型。

public:
generic <typename TOther>
 where TOther : class System::Collections::Immutable::ImmutableArray<TOther> As();
public System.Collections.Immutable.ImmutableArray<TOther> As<TOther>() where TOther : class;
member this.As : unit -> System.Collections.Immutable.ImmutableArray<'Other (requires 'Other : null)> (requires 'Other : null)
Public Function As(Of TOther As Class) () As ImmutableArray(Of TOther)

类型参数

TOther

要返回的数组元素的类型。

返回

ImmutableArray<TOther>

包含此数组的元素的不可变数组,转换为其他类型。 如果强制转换失败,则返回其属性返回的IsDefaulttrue数组。

注解

派生元素类型的数组可以强制转换为基元素类型的数组,而无需重新分配数组。

可以使用该方法反转使用Create该方法创建的As元素。 但是,仅当向下转换扭转以前的上一个倒播时,向下转换才成功。 操作。

适用于