MemoryMarshal.TryGetArray<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.
Tries to get an array segment from the underlying memory buffer. The return value indicates the success of the operation.
public:
generic <typename T>
static bool TryGetArray(ReadOnlyMemory<T> memory, [Runtime::InteropServices::Out] ArraySegment<T> % segment);
public static bool TryGetArray<T> (ReadOnlyMemory<T> memory, out ArraySegment<T> segment);
static member TryGetArray : ReadOnlyMemory<'T> * ArraySegment -> bool
Public Shared Function TryGetArray(Of T) (memory As ReadOnlyMemory(Of T), ByRef segment As ArraySegment(Of T)) As Boolean
Type Parameters
- T
The type of items in the read-only memory buffer.
Parameters
- memory
- ReadOnlyMemory<T>
A read-only memory buffer.
- segment
- ArraySegment<T>
When this method returns, contains the array segment retrieved from the underlying read-only memory buffer. If the method fails, the method returns a default array segment.
Returns
true
if the method call succeeds; false
otherwise.
Remarks
Caution
ReadOnlyMemory<T> is used to represent immutable data. ArraySegment<T> instances returned by this method should not be written to, and the wrapped array instance should only be passed to methods which treat the array contents as read-only.