語言

Unsafe.AddByteOffset 方法

定義

多載

名稱 Description
AddByteOffset<T>(T, IntPtr)

為所管理指標增加一個位元組偏移量。

AddByteOffset<T>(T, UIntPtr)

為所管理指標增加一個位元組偏移量。

AddByteOffset<T>(T, IntPtr)

來源:
Unsafe.cs
來源:
Unsafe.cs
來源:
Unsafe.cs
來源:
Unsafe.cs
來源:
Unsafe.cs

為所管理指標增加一個位元組偏移量。

public:
generic <typename T>
 static T % AddByteOffset(T % source, IntPtr byteOffset);
public static ref T AddByteOffset<T>(ref T source, IntPtr byteOffset) where T : allows ref struct;
public static ref T AddByteOffset<T>(ref T source, IntPtr byteOffset);
static member AddByteOffset : 'T * nativeint -> 'T
Public Shared Function AddByteOffset(Of T) (ByRef source As T, byteOffset As IntPtr) As T

類型參數

T

管理指標的元素型態。

參數

source
T

管理指標要加上偏移量。

byteOffset
IntPtr

nativeint

要加上偏移。

傳回

T

一個新的管理指標,反映將指定的位元組偏移量加入來源指標。

備註

參數 byteOffset 是要加入 source 指標的位元組數。 例如,給定一個類型ref int為 的來源指標 ptr,呼叫Unsafe.AddByteOffset<int>(ref ptr, 20)會回傳一個新的指標,其位址指向 ptr 之外 20 位元組。

如果 byteOffset 是計算值而非硬編碼的字面值,呼叫者應考慮整數溢位的可能性。 例如,在呼叫 Unsafe.AddByteOffset<int>(ref ptr, a * b)中,呼叫者必須確保中間值 a * b 不會超出 的 IntPtr範圍。

適用於

AddByteOffset<T>(T, UIntPtr)

來源:
Unsafe.cs
來源:
Unsafe.cs
來源:
Unsafe.cs
來源:
Unsafe.cs
來源:
Unsafe.cs

重要

此 API 不符合 CLS 規範。

為所管理指標增加一個位元組偏移量。

public:
generic <typename T>
 static T % AddByteOffset(T % source, UIntPtr byteOffset);
[System.CLSCompliant(false)]
public static ref T AddByteOffset<T>(ref T source, UIntPtr byteOffset) where T : allows ref struct;
public static ref T AddByteOffset<T>(ref T source, nuint byteOffset);
[System.CLSCompliant(false)]
public static ref T AddByteOffset<T>(ref T source, UIntPtr byteOffset);
[<System.CLSCompliant(false)>]
static member AddByteOffset : 'T * unativeint -> 'T
static member AddByteOffset : 'T * unativeint -> 'T
Public Shared Function AddByteOffset(Of T) (ByRef source As T, byteOffset As UIntPtr) As T

類型參數

T

管理指標的元素型態。

參數

source
T

管理指標要加上偏移量。

byteOffset
UIntPtr

nuint

unativeint

要加上偏移。

傳回

T

一個新的管理指標,反映將指定的位元組偏移量加入來源指標。

屬性

備註

參數 byteOffset 是要加入 source 指標的位元組數。 例如,給定一個類型ref int為 的來源指標 ptr,呼叫Unsafe.AddByteOffset<int>(ref ptr, (nuint)20)會回傳一個新的指標,其位址指向 ptr 之外 20 位元組。

如果 byteOffset 是計算值而非硬編碼的字面值,呼叫者應考慮整數溢位的可能性。 例如,在呼叫 Unsafe.AddByteOffset<int>(ref ptr, a * b)中,呼叫者必須確保中間值 a * b 不會超出 的 UIntPtr範圍。

適用於