Show / Hide Table of Contents

Class MemoryMarshalExtensions

Provides low-level extensions to work with the memory.

Inheritance
object
MemoryMarshalExtensions
Inherited Members
object.GetType()
object.MemberwiseClone()
object.ToString()
object.Equals(object)
object.Equals(object, object)
object.ReferenceEquals(object, object)
object.GetHashCode()
Namespace: DotNext.Runtime.InteropServices
Assembly: DotNext.dll
Syntax
public static class MemoryMarshalExtensions

Methods

View Source

AsBytes<T>(ref T)

Converts contiguous memory identified by the specified pointer into Span<T>.

Declaration
public static Span<byte> AsBytes<T>(ref T value) where T : unmanaged, allows ref struct
Parameters
Type Name Description
T value

The managed pointer.

Returns
Type Description
Span<byte>

The span of contiguous memory.

Type Parameters
Name Description
T
View Source

AsReadOnlyBytes<T>(ref readonly T)

Converts contiguous memory identified by the specified pointer into ReadOnlySpan<T>.

Declaration
public static ReadOnlySpan<byte> AsReadOnlyBytes<T>(ref readonly T value) where T : unmanaged, allows ref struct
Parameters
Type Name Description
T value

The managed pointer.

Returns
Type Description
ReadOnlySpan<byte>

The span of contiguous memory.

Type Parameters
Name Description
T
View Source

ToEnumerator<T>(ReadOnlyMemory<T>)

Gets enumerator over all elements in the memory.

Declaration
public static IEnumerator<T> ToEnumerator<T>(ReadOnlyMemory<T> memory)
Parameters
Type Name Description
ReadOnlyMemory<T> memory

The memory block to be converted.

Returns
Type Description
IEnumerator<T>

The enumerator over all elements in the memory.

Type Parameters
Name Description
T

The type of elements in the memory.

See Also
ToEnumerable<T>(ReadOnlyMemory<T>)
  • View Source
☀
☾
In this article
Back to top
Supported by the .NET Foundation
☀
☾