ImmutableArray<T>.As ImmutableArray<T>.As ImmutableArray<T>.As ImmutableArray<T>.As Method


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

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


The type of array element to return.



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.


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