Class MemoryMarshalExtensions
Provides low-level extensions to work with the memory.
Inherited Members
Namespace: DotNext.Runtime.InteropServices
Assembly: DotNext.dll
Syntax
public static class MemoryMarshalExtensions
Methods
View SourceAsBytes<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 |
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 |
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>)