ImmutableArray<T>.As<TOther> Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
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
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
反馈
https://aka.ms/ContentUserFeedback。
即将发布:在整个 2024 年,我们将逐步淘汰作为内容反馈机制的“GitHub 问题”,并将其取代为新的反馈系统。 有关详细信息,请参阅:提交和查看相关反馈