SpanExtensions.Cast<TFrom,TTo>(Span<TFrom>) 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.
Casts a Span<T> of one primitive type TFrom
to another primitive type TTo
.
These types may not contain pointers or references. This is checked at runtime in order to preserve type safety.
public static Span<TTo> Cast<TFrom,TTo> (this Span<TFrom> span) where TFrom : struct where TTo : struct;
static member Cast : Span<'From (requires 'From : struct)> -> Span<'o (requires 'o : struct)> (requires 'From : struct and 'o : struct)
<Extension()>
Public Function Cast(Of TFrom As Structure, TTo As Structure) (span As Span(Of TFrom)) As Span(Of TTo)
Type Parameters
- TFrom
The type of items in the source Span<T>.
- TTo
The type of items in the destination Span<T>.
Parameters
- span
- Span<TFrom>
The source slice, of type TFrom
.
Returns
A Span<T> of type TTo
Exceptions
Thrown when TFrom
or TTo
contains pointers.
Remarks
Supported only for platforms that support misaligned memory access or when the memory block is aligned by other means.