Click or drag to resize

ReadOnlyMemoryT Structure

Compatibility shim of ReadOnlyMemoryT for .NET Framework targets.

Unlike the official type it can be backed either by a managed array or by a native pointer. A managed array is never exposed through a raw pointer unless pinned: use TryGetArray(ArraySegmentT) or Pin. Span is available only for native-backed instances.

Inheritance Hierarchy
SystemObject
  SystemValueType
    SystemReadOnlyMemoryT

Namespace: System
Assembly: C2JBridge (in C2JBridge.dll) Version: 2.6.10.261112-5ffe0920c00dbac056780af7ab9b1978b26ef4a5
Syntax
public readonly struct ReadOnlyMemory<T>
where T : struct, new()

Type Parameters

T
The type of elements. Must be an unmanaged type.

The ReadOnlyMemoryT type exposes the following members.

Constructors
 NameDescription
Public methodReadOnlyMemoryT(T)Creates a memory over the entirety of an array. A null array gives an empty memory.
Public methodReadOnlyMemoryT(Void*, Int32) Creates a memory over native memory. The caller guarantees that the memory stays valid and fixed for the whole lifetime of the instance and of any copy of it.
Public methodReadOnlyMemoryT(T, Int32, Int32)Creates a memory over a portion of an array.
Top
Properties
 NameDescription
Public propertyStatic memberEmptyGets an empty ReadOnlyMemoryT.
Public propertyIsEmptyGets a value indicating whether this memory is empty.
Public propertyIsNativeGets a value indicating whether this memory is backed by native memory.
Public propertyLengthGets the number of elements in the memory region.
Public propertySpan Gets the span over this memory. Supported only for native-backed (or empty) instances: a managed array cannot be exposed through a raw pointer without pinning it.
Top
Methods
 NameDescription
Public methodCopyToCopies the content into a destination array.
Public methodEqualsIndicates whether this instance and a specified object are equal.
(Inherited from ValueType)
Public methodGetHashCodeReturns the hash code for this instance.
(Inherited from ValueType)
Public methodGetTypeGets the Type of the current instance.
(Inherited from Object)
Public methodPin Pins the memory and returns a handle exposing a stable pointer to the first element. The handle must be disposed. For native-backed memory no pinning is needed.
Public methodSlice(Int32)Forms a slice starting at the specified index.
Public methodSlice(Int32, Int32)Forms a slice of the specified length starting at the specified index.
Public methodToArrayCopies the content into a new array.
Public methodToStringReturns the fully qualified type name of this instance.
(Inherited from ValueType)
Public methodTryGetArrayTries to get the underlying array segment. Returns false for native-backed memory.
Top
Operators
 NameDescription
Public operatorStatic member(ArraySegmentT to ReadOnlyMemoryT)Implicitly converts an ArraySegmentT to a ReadOnlyMemoryT.
Public operatorStatic member(T to ReadOnlyMemoryT)Implicitly converts an array to a ReadOnlyMemoryT.
Top
Extension Methods
 NameDescription
Public Extension MethodConvertTReturn Converts a generic object
(Defined by JCOBridgeExtensions)
Public Extension MethodToNative Converts a generic input to an object manageable from the JVM
(Defined by JCOBridgeExtensions)
Top
See Also