MemoryOwner<T>.Slice(Int32, Int32) 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.
Slices the buffer currently in use and returns a new MemoryOwner<T> instance.
public Microsoft.Toolkit.HighPerformance.Buffers.MemoryOwner<T> Slice (int start, int length);
member this.Slice : int * int -> Microsoft.Toolkit.HighPerformance.Buffers.MemoryOwner<'T>
Public Function Slice (start As Integer, length As Integer) As MemoryOwner(Of T)
Parameters
- start
- Int32
The starting offset within the current buffer.
- length
- Int32
The length of the buffer to use.
Returns
A new MemoryOwner<T> instance using the target range of items.
Exceptions
Thrown when the buffer in use has already been disposed.
Thrown when start
or length
are not valid.
Remarks
Using this method will dispose the current instance, and should only be used when an oversized buffer is rented and then adjusted in size, to avoid having to rent a new buffer of the new size and copy the previous items into the new one, or needing an additional variable/field to manually handle to track the used range within a given MemoryOwner<T> instance.