MemoryMarshal MemoryMarshal MemoryMarshal MemoryMarshal Class

Definition

Provides methods to interoperate with Memory<T>, ReadOnlyMemory<T>, Span<T>, and ReadOnlySpan<T>.

public ref class MemoryMarshal abstract sealed
public static class MemoryMarshal
type MemoryMarshal = class
Public Class MemoryMarshal
Inheritance
MemoryMarshalMemoryMarshalMemoryMarshalMemoryMarshal

Methods

AsBytes<T>(ReadOnlySpan<T>) AsBytes<T>(ReadOnlySpan<T>) AsBytes<T>(ReadOnlySpan<T>) AsBytes<T>(ReadOnlySpan<T>)

Casts a ReadOnlySpan<T> of one primitive type, T, to a ReadOnlySpan<Byte>.

AsBytes<T>(Span<T>) AsBytes<T>(Span<T>) AsBytes<T>(Span<T>) AsBytes<T>(Span<T>)

Casts a Span<T> of one primitive type, T, to a Span<Byte>.

AsMemory<T>(ReadOnlyMemory<T>) AsMemory<T>(ReadOnlyMemory<T>) AsMemory<T>(ReadOnlyMemory<T>) AsMemory<T>(ReadOnlyMemory<T>)

Creates a Memory<T> instance from a ReadOnlyMemory<T>.

AsRef<T>(ReadOnlySpan<Byte>) AsRef<T>(ReadOnlySpan<Byte>) AsRef<T>(ReadOnlySpan<Byte>) AsRef<T>(ReadOnlySpan<Byte>)

Reinterprets a read-only span of bytes as a read-only reference to the structure of type T.

AsRef<T>(Span<Byte>) AsRef<T>(Span<Byte>) AsRef<T>(Span<Byte>) AsRef<T>(Span<Byte>)

Reinterprets a span of bytes as a reference to the structure of type T.

Cast<TFrom,TTo>(ReadOnlySpan<TFrom>) Cast<TFrom,TTo>(ReadOnlySpan<TFrom>) Cast<TFrom,TTo>(ReadOnlySpan<TFrom>) Cast<TFrom,TTo>(ReadOnlySpan<TFrom>)

Casts a read-only span of one primitive type to a read-only span of another primitive type.

Cast<TFrom,TTo>(Span<TFrom>) Cast<TFrom,TTo>(Span<TFrom>) Cast<TFrom,TTo>(Span<TFrom>) Cast<TFrom,TTo>(Span<TFrom>)

Casts a span of one primitive type to a span of another primitive type.

CreateFromPinnedArray<T>(T[], Int32, Int32) CreateFromPinnedArray<T>(T[], Int32, Int32) CreateFromPinnedArray<T>(T[], Int32, Int32) CreateFromPinnedArray<T>(T[], Int32, Int32)

Creates a new memory buffer over the portion of the pre-pinned target array beginning at the start index and consisting of length items.

CreateReadOnlySpan<T>(T, Int32) CreateReadOnlySpan<T>(T, Int32) CreateReadOnlySpan<T>(T, Int32) CreateReadOnlySpan<T>(T, Int32)

Creates a new read-only span over a portion of a regular managed object.

CreateSpan<T>(T, Int32) CreateSpan<T>(T, Int32) CreateSpan<T>(T, Int32) CreateSpan<T>(T, Int32)

Creates a new span over a portion of a regular managed object.

GetReference<T>(Span<T>) GetReference<T>(Span<T>) GetReference<T>(Span<T>) GetReference<T>(Span<T>)

Returns a reference to the element of the span at index 0.

GetReference<T>(ReadOnlySpan<T>) GetReference<T>(ReadOnlySpan<T>) GetReference<T>(ReadOnlySpan<T>) GetReference<T>(ReadOnlySpan<T>)

Returns a reference to the element of the read-only span at index 0.

Read<T>(ReadOnlySpan<Byte>) Read<T>(ReadOnlySpan<Byte>) Read<T>(ReadOnlySpan<Byte>) Read<T>(ReadOnlySpan<Byte>)

Reads a structure of type out of a read-only span of bytes.

ToEnumerable<T>(ReadOnlyMemory<T>) ToEnumerable<T>(ReadOnlyMemory<T>) ToEnumerable<T>(ReadOnlyMemory<T>) ToEnumerable<T>(ReadOnlyMemory<T>)

Creates an IEnumerable<T> view of the given read-only memory buffer.

TryGetArray<T>(ReadOnlyMemory<T>, ArraySegment<T>) TryGetArray<T>(ReadOnlyMemory<T>, ArraySegment<T>) TryGetArray<T>(ReadOnlyMemory<T>, ArraySegment<T>) TryGetArray<T>(ReadOnlyMemory<T>, ArraySegment<T>)

Tries to get an array segment from the underlying memory buffer. The return value indicates the success of the operation.

TryGetMemoryManager<T,TManager>(ReadOnlyMemory<T>, TManager) TryGetMemoryManager<T,TManager>(ReadOnlyMemory<T>, TManager) TryGetMemoryManager<T,TManager>(ReadOnlyMemory<T>, TManager) TryGetMemoryManager<T,TManager>(ReadOnlyMemory<T>, TManager)

Tries to retrieve a MemoryManager<T> from the underlying read-only memory buffer.

TryGetMemoryManager<T,TManager>(ReadOnlyMemory<T>, TManager, Int32, Int32) TryGetMemoryManager<T,TManager>(ReadOnlyMemory<T>, TManager, Int32, Int32) TryGetMemoryManager<T,TManager>(ReadOnlyMemory<T>, TManager, Int32, Int32) TryGetMemoryManager<T,TManager>(ReadOnlyMemory<T>, TManager, Int32, Int32)

Tries to retrieve a MemoryManager<T>, start index, and length from the underlying read-only memory buffer.

TryGetString(ReadOnlyMemory<Char>, String, Int32, Int32) TryGetString(ReadOnlyMemory<Char>, String, Int32, Int32) TryGetString(ReadOnlyMemory<Char>, String, Int32, Int32) TryGetString(ReadOnlyMemory<Char>, String, Int32, Int32)

Tries to get the underlying string from a System.ReadOnlyMemory<Char>.

TryRead<T>(ReadOnlySpan<Byte>, T) TryRead<T>(ReadOnlySpan<Byte>, T) TryRead<T>(ReadOnlySpan<Byte>, T) TryRead<T>(ReadOnlySpan<Byte>, T)

Tries to read a structure of type T from a read-only span of bytes.

TryWrite<T>(Span<Byte>, T) TryWrite<T>(Span<Byte>, T) TryWrite<T>(Span<Byte>, T) TryWrite<T>(Span<Byte>, T)

Tries to write a structure of type T into a span of bytes.

Write<T>(Span<Byte>, T) Write<T>(Span<Byte>, T) Write<T>(Span<Byte>, T) Write<T>(Span<Byte>, T)

Writes a structure of type T into a span of bytes.

Applies to