แก้ไข

แชร์ผ่าน


ImmutableArray<T>.As<TOther> Method

Definition

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)

Type Parameters

TOther

The type of array element to return.

Returns

ImmutableArray<TOther>

An immutable array that contains the elements of this array, cast to a different type. If the cast fails, returns an array whose IsDefault property returns true.

Remarks

Arrays of derived elements types can be cast to arrays of base element types without reallocating the array.

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.

Applies to