Show / Hide Table of Contents

Interface IUnmanagedMemory<T>

Represents unmanaged memory owner.

Inherited Members
IUnmanagedMemory.Clear()
IUnmanagedMemory.AsStream()
IUnmanagedMemory.Size
IUnmanagedMemory.Bytes
IMemoryOwner<T>.Memory
IDisposable.Dispose()
ISupplier<Memory<T>>.Invoke()
IFunctional.DynamicInvoke(scoped ref readonly Variant, int, scoped Variant)
IFunctional.GetArgument<T>(ref readonly Variant, int)
Namespace: DotNext.Runtime.InteropServices
Assembly: DotNext.Unsafe.dll
Syntax
[CLSCompliant(false)]
[NativeMarshalling(typeof(UnmanagedMemoryMarshaller<>))]
public interface IUnmanagedMemory<T> : IUnmanagedMemory, IMemoryOwner<T>, IDisposable, ISupplier<Memory<T>>, IFunctional where T : unmanaged
Type Parameters
Name Description
T

The type of elements in the unmanaged memory.

Properties

View Source

this[int]

Gets element of the unmanaged array.

Declaration
ref T this[int index] { get; }
Parameters
Type Name Description
int index

The index of the element to get.

Property Value
Type Description
T

The pointer to the array element.

Exceptions
Type Condition
ArgumentOutOfRangeException

index is out of range.

View Source

Length

Gets the number of elements in the unmanaged memory.

Declaration
int Length { get; }
Property Value
Type Description
int
View Source

Pointer

Gets a pointer to the allocated unmanaged memory.

Declaration
Pointer<T> Pointer { get; }
Property Value
Type Description
Pointer<T>
View Source

Span

Gets a span from the current instance.

Declaration
Span<T> Span { get; }
Property Value
Type Description
Span<T>
View Source

SupportsReallocation

Gets a value indicating that the referenced memory can be reallocated.

Declaration
bool SupportsReallocation { get; }
Property Value
Type Description
bool

Methods

View Source

Reallocate(int)

Resizes a block of memory represented by this instance.

Declaration
void Reallocate(int length)
Parameters
Type Name Description
int length

The new number of elements in the unmanaged array.

Remarks

This method is dangerous because it invalidates all buffers returned by Memory property.

Exceptions
Type Condition
ObjectDisposedException

The underlying unmanaged memory is released.

ArgumentOutOfRangeException

length is less than or equal to zero.

NotSupportedException

Reallocation is not supported.

See Also
SupportsReallocation

Extension Methods

BasicExtensions.As<T>(T)
BasicExtensions.IsBetween<T, TLowerBound, TUpperBound>(T, TLowerBound, TUpperBound)
BasicExtensions.IsOneOf<T>(T, params ReadOnlySpan<T>)
  • View Source
☀
☾
In this article
Back to top
Supported by the .NET Foundation
☀
☾