Click or drag to resize

ReadOnlySpanT Structure

Compatibility shim of ReadOnlySpanT for .NET Framework targets.

This type is provided solely to allow JCOBridge public APIs that expose ReadOnlySpanT (such as AsSpan and AsSpan) to compile and function correctly on .NET Framework without any external dependency. The implementation is backed by native pointer arithmetic and covers the subset of the API required by JCOBridge consumers.

JCOBridge HPA edition on .NET Framework uses the official System.ReadOnlySpan<T> from the System.Memory NuGet package, which provides the full runtime-optimised implementation including SIMD support.

Users targeting .NET 5+ or .NET Standard 2.1 always receive the official runtime type — this shim is never compiled into those targets.

Inheritance Hierarchy
SystemObject
  SystemValueType
    SystemReadOnlySpanT

Namespace: System
Assembly: C2JBridge (in C2JBridge.dll) Version: 2.6.9.260611-9a148513a79c26cdd7f1dde468f4f9e06ef3bc7e
Syntax
public readonly ref struct ReadOnlySpan<T>
where T : struct, new()

Type Parameters

T
The type of elements in the span. Must be an unmanaged type.

The ReadOnlySpanT type exposes the following members.

Constructors
 NameDescription
Public methodReadOnlySpanT(T) Creates a new ReadOnlySpanT over the entirety of a target array.
Public methodReadOnlySpanT(Void*, Int32) Creates a new ReadOnlySpanT from a raw pointer and a length.
Top
Properties
 NameDescription
Public propertyStatic memberEmptyGets an empty ReadOnlySpanT.
Public propertyIsEmptyGets a value indicating whether this span is empty.
Public propertyItem Returns the element at the specified index.
Top
Methods
 NameDescription
Public methodStatic memberCastUpTDerived Not supported on .NET Framework.

CastUp<TDerived> exists for reference-type covariance (e.g. ReadOnlySpan<string>ReadOnlySpan<object>), which is incompatible with the where T : unmanaged constraint required by this shim. Unmanaged types are never reference types and therefore covariant casting is meaningless in this context.


Obsolete
Public methodCopyTo(SpanT) Copies the contents of this span into a destination SpanT.
Public methodCopyTo(T, Int32) Copies the contents of this span into a destination array.
Public methodEqualsIndicates whether this instance and a specified object are equal.
(Inherited from ValueType)
Public methodGetEnumeratorReturns an enumerator for this span, enabling foreach support.
Public methodGetHashCodeReturns the hash code for this instance.
(Inherited from ValueType)
Public methodGetPinnableReference Returns a reference to the first element for use with the fixed statement. Not intended to be called by user code.
Public methodGetTypeGets the Type of the current instance.
(Inherited from Object)
Public methodSequenceEqual Determines whether this span and other contain the same sequence of elements, using a native memcmp comparison.
Public methodSlice(Int32) Forms a slice out of the current span starting at the specified index.
Public methodSlice(Int32, Int32) Forms a slice out of the current span starting at the specified index for the specified length.
Public methodToArray Copies the contents of this span into a new array.
Public methodToStringReturns the fully qualified type name of this instance.
(Inherited from ValueType)
Public methodTryCopyTo Attempts to copy the contents of this span into a destination SpanT and returns a value indicating whether the operation succeeded.
Top
Operators
 NameDescription
Public operatorStatic member(T to ReadOnlySpanT)Implicitly converts a T array to a ReadOnlySpanT.
Top
Fields
 NameDescription
Public fieldLengthGets the number of elements in the span.
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