Redigera

Dela via


MemoryMarshal.GetArrayDataReference Method

Definition

Overloads

GetArrayDataReference(Array)

Returns a reference to the 0th element of array. If the array is empty, returns a reference to where the 0th element would have been stored. Such a reference may be used for pinning but must never be dereferenced.

GetArrayDataReference<T>(T[])

Returns a reference to the 0th element of array. If the array is empty, returns a reference to where the 0th element would have been stored. Such a reference may be used for pinning but must never be dereferenced.

GetArrayDataReference(Array)

Source:
MemoryMarshal.CoreCLR.cs
Source:
MemoryMarshal.CoreCLR.cs
Source:
MemoryMarshal.CoreCLR.cs

Returns a reference to the 0th element of array. If the array is empty, returns a reference to where the 0th element would have been stored. Such a reference may be used for pinning but must never be dereferenced.

public:
 static System::Byte % GetArrayDataReference(Array ^ array);
public static ref byte GetArrayDataReference (Array array);
static member GetArrayDataReference : Array -> byte
Public Shared Function GetArrayDataReference (array As Array) As Byte

Parameters

array
Array

The array to analyze.

Returns

A reference to the 0th element of array.

Exceptions

array is null.

Remarks

The caller must manually reinterpret the returned ref byte as a ref to the array's underlying elemental type, perhaps utilizing an API such as System.Runtime.CompilerServices.Unsafe.As to assist with the reinterpretation. This technique does not perform array variance checks. The caller must manually perform any array variance checks if the caller wishes to write to the returned reference.

Applies to

GetArrayDataReference<T>(T[])

Source:
MemoryMarshal.CoreCLR.cs
Source:
MemoryMarshal.CoreCLR.cs
Source:
MemoryMarshal.CoreCLR.cs

Returns a reference to the 0th element of array. If the array is empty, returns a reference to where the 0th element would have been stored. Such a reference may be used for pinning but must never be dereferenced.

public:
generic <typename T>
 static T % GetArrayDataReference(cli::array <T> ^ array);
public static ref T GetArrayDataReference<T> (T[] array);
static member GetArrayDataReference : 'T[] -> 'T
Public Shared Function GetArrayDataReference(Of T) (array As T()) As T

Type Parameters

T

The type of the array elements.

Parameters

array
T[]

The array to analyze.

Returns

T

Reference to the 0th element in array.

Exceptions

array is null.

Remarks

This method does not perform array variance checks. The caller must manually perform any array variance checks if the caller wishes to write to the returned reference.

Applies to