Upraviť

Zdieľať cez


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
MemoryMarshal

Methods

AsBytes<T>(ReadOnlySpan<T>)

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

AsBytes<T>(Span<T>)

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

AsMemory<T>(ReadOnlyMemory<T>)

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

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>)

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

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>)

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

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)

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

CreateReadOnlySpanFromNullTerminated(Byte*)

Creates a new read-only span for a null-terminated sequence of bytes.

CreateReadOnlySpanFromNullTerminated(Char*)

Creates a new read-only span for a null-terminated string.

CreateSpan<T>(T, Int32)

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

GetArrayDataReference(Array)

Returns a reference to the 0th element of array. If the array is empty, returns a reference to where the 0th element would have been stored. Such a reference may be used for pinning but must never be dereferenced.

GetArrayDataReference<T>(T[])

Returns a reference to the 0th element of array. If the array is empty, returns a reference to where the 0th element would have been stored. Such a reference may be used for pinning but must never be dereferenced.

GetReference<T>(ReadOnlySpan<T>)

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

GetReference<T>(Span<T>)

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

Read<T>(ReadOnlySpan<Byte>)

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

ToEnumerable<T>(ReadOnlyMemory<T>)

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

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, Int32, Int32)

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

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

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

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

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

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)

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

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

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

Applies to