ImmutableArray<T>.As<TOther> 方法

定义

返回一个新的不可变数组,其中包含此数组的已转换成不同类型的元素。Returns a new immutable array that contains the elements of this array cast to a different type.

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

要返回的数组元素类型。The type of array element to return.

返回

ImmutableArray<TOther>

一个不可变数组,其中包含此数组的已转换成不同类型的元素。An immutable array that contains the elements of this array, cast to a different type. 如果转换失败,则返回其 IsDefault 属性将返回 true 的数组。If the cast fails, returns an array whose IsDefault property returns true.

注解

派生元素类型的数组可以强制转换为基元素类型的数组,而不会重新分配数组。Arrays of derived elements types can be cast to arrays of base element types without reallocating the array.

使用 Create 方法创建的元素的向上转换可以使用 @no__t 的方法反转。Upcasts of element created with the Create method can be reversed using the As method. 但是,仅当向下转换反转之前的向上转换时才会成功。However, a downcast is only successful when it reverses a prior upcast. 名称。operation.

适用于