ListExtensions.AsSpan<T>(List<T>) 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.
public static Span<T> AsSpan<T> (this System.Collections.Generic.List<T>? list);
static member AsSpan : System.Collections.Generic.List<'T> -> Span<'T>
<Extension()>
Public Function AsSpan(Of T) (list As List(Of T)) As Span(Of T)
Type Parameters
- T
The type of elements in the input List<T> instance.
Parameters
Returns
A Span<T> instance with the values of list
.
Remarks
Note that the returned Span<T> is only guaranteed to be valid as long as the items within list
are not modified. Doing so might cause the List<T> to swap its internal buffer, causing the returned Span<T> to become out of date. That means that in this scenario, the Span<T> would end up wrapping an array no longer in use. Always make sure to use the returned Span<T> while the target List<T> is not modified.