ImmutableArray<T>::As<TOther> Method ()

 

Returns a new immutable array that contains the elements of this array cast to a different type.

Namespace:   System.Collections.Immutable
Assembly:  System.Collections.Immutable (in System.Collections.Immutable.dll)

public:
generic<typename TOther>
where TOther : ref class
ImmutableArray<TOther> As()

Return Value

Type: System.Collections.Immutable::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.

Type Parameters

TOther

The type of array element to return.

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<T, TDerived> method can be reversed using the As<TOther> method. However, a downcast is only successful when it reverses a prior upcast. operation.

Return to top
Show: