Method CastUp
CastUp<TDerived>(ReadOnlyExSpan<TDerived>)
Casts a read-only ExSpan of TDerived
to a read-only ExSpan of T
.
public static ReadOnlyExSpan<T> CastUp<TDerived>(ReadOnlyExSpan<TDerived> items) where TDerived : class?, T
Parameters
items
ReadOnlyExSpan<TDerived>The source read-only ExSpan. No copy is made.
Returns
- ReadOnlyExSpan<T>
A read-only ExSpan with elements cast to the new type.
Type Parameters
TDerived
The element type of the source read-only ExSpan, which must be derived from
T
.
Remarks
This method uses a covariant cast, producing a read-only ExSpan that shares the same memory as the source. The relationships expressed in the type constraints ensure that the cast is a safe operation.