Marshal. Create Span<T>(T, Int32) Method
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.
Creates a new span over a portion of a regular managed object.
public: generic <typename T> static Span<T> CreateSpan(T % reference, int length);
public static Span<T> CreateSpan<T> (ref T reference, int length);
public static Span<T> CreateSpan<T> (scoped ref T reference, int length);
static member CreateSpan : 'T * int -> Span<'T>
Public Shared Function CreateSpan(Of T) (ByRef reference As T, length As Integer) As Span(Of T)
The type of the data items.
A reference to data.
The number of
T elements that
This method can be useful if part of a managed object represents a fixed array.
This method should be used with caution. It is dangerous because the
length argument is not checked. Even though the
ref is annotated as
scoped, it will be stored into the returned span, and the lifetime of the returned span will not be validated for safety, even by span-aware languages.