MemoryMarshal.GetReference Method

Definition

Overloads

GetReference<T>(ReadOnlySpan<T>)

Returns a reference to the element of the read-only span at index 0.

GetReference<T>(Span<T>)

Returns a reference to the element of the span at index 0.

GetReference<T>(ReadOnlySpan<T>)

Returns a reference to the element of the read-only span at index 0.

public:
generic <typename T>
 static T % GetReference(ReadOnlySpan<T> span);
public static ref T GetReference<T> (ReadOnlySpan<T> span);
static member GetReference : ReadOnlySpan<'T> -> 'T
Public Shared Function GetReference(Of T) (span As ReadOnlySpan(Of T)) As T

Type Parameters

T

The type of items in the span.

Parameters

span
ReadOnlySpan<T>

The read-only span from which the reference is retrieved.

Returns

T

A reference to the element at index 0.

Remarks

If the read-only span is empty, this method returns a reference to the location where the element at index 0 would have been stored. Such a reference may or may not be null. The returned reference can be used for pinning, but it must never be dereferenced.

GetReference<T>(Span<T>)

Returns a reference to the element of the span at index 0.

public:
generic <typename T>
 static T % GetReference(Span<T> span);
public static ref T GetReference<T> (Span<T> span);
static member GetReference : Span<'T> -> 'T
Public Shared Function GetReference(Of T) (span As Span(Of T)) As T

Type Parameters

T

The type of items in the span.

Parameters

span
Span<T>

The span from which the reference is retrieved.

Returns

T

A reference to the element at index 0.

Remarks

If the span is empty, this method returns a reference to the location where the element at index 0 would have been stored. Such a reference may or may not be null. The returned reference can be used for pinning, but it must never be dereferenced.

Applies to