MemoryMarshal MemoryMarshal MemoryMarshal MemoryMarshal Class

定义

提供与 Memory<T>ReadOnlyMemory<T>Span<T>ReadOnlySpan<T> 进行交互操作的方法。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
继承
MemoryMarshalMemoryMarshalMemoryMarshalMemoryMarshal

方法

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

将一种基元类型 TReadOnlySpan<T> 强制转换为 ReadOnlySpan<Byte>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>)

将一种基元类型 TSpan<T> 强制转换为 Span<Byte>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>)

通过 Memory<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>)
AsRef<T>(Span<Byte>) AsRef<T>(Span<Byte>) AsRef<T>(Span<Byte>) AsRef<T>(Span<Byte>)
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)

start 索引开始并包含 length 项,在预固定目标数组的一部分之上创建新的内存缓冲区。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>)

返回对索引为 0 处范围元素的引用。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>)

返回对索引为 0 处只读范围元素的引用。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>)

创建给定的只读内存缓冲区的 IEnumerable<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)

尝试从基础只读内存缓冲区中检索 MemoryManager<T>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)

尝试从基础只读内存缓冲区中检索 MemoryManager<T>、起始索引和长度。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)

尝试从 System.ReadOnlyMemory<Char> 中获取基础字符串。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)

尝试从字节的只读范围中读取 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)

尝试将 T 类型的结构写入字节范围。Tries to writes 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)

T 类型的结构写入字节范围内。Writes a structure of type T into a span of bytes.

适用于