Unsafe.SubtractByteOffset 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
多載
| 名稱 | Description |
|---|---|
| SubtractByteOffset<T>(T, IntPtr) |
從指定的Managed指標減去位元組位移。 |
| SubtractByteOffset<T>(T, UIntPtr) |
從指定的Managed指標減去位元組位移。 |
SubtractByteOffset<T>(T, IntPtr)
- 來源:
- Unsafe.cs
- 來源:
- Unsafe.cs
- 來源:
- Unsafe.cs
- 來源:
- Unsafe.cs
從指定的Managed指標減去位元組位移。
public:
generic <typename T>
static T % SubtractByteOffset(T % source, IntPtr byteOffset);
public static ref T SubtractByteOffset<T>(ref T source, IntPtr byteOffset) where T : allows ref struct;
public static ref T SubtractByteOffset<T>(ref T source, IntPtr byteOffset);
static member SubtractByteOffset : 'T * nativeint -> 'T
Public Shared Function SubtractByteOffset(Of T) (ByRef source As T, byteOffset As IntPtr) As T
類型參數
- T
Managed 指標的專案型別。
參數
- source
- T
要減去位移的Managed指標。
- byteOffset
-
IntPtr
nativeint
要減去的位移。
傳回
新的 Managed 指標,反映來源指標中指定位元組位移的減法。
備註
參數 byteOffset 是從指標中移除 source 的位元元組數目。 例如,假設類型為 的來源指標 ptrref int,呼叫Unsafe.SubtractByteOffset<int>(ref ptr, 20)會傳回新的指標,其位址點在 ptr 之前為 20 個字節。
如果 byteOffset 是計算值,而不是硬式編碼常值,呼叫端應該考慮整數溢位的可能性。 例如,在呼叫 中,呼叫 Unsafe.SubtractByteOffset<int>(ref ptr, a * b)端必須確定中繼值 a * b 不會溢位 的界限 IntPtr。
適用於
SubtractByteOffset<T>(T, UIntPtr)
- 來源:
- Unsafe.cs
- 來源:
- Unsafe.cs
- 來源:
- Unsafe.cs
- 來源:
- Unsafe.cs
重要
此 API 不符合 CLS 規範。
從指定的Managed指標減去位元組位移。
public:
generic <typename T>
static T % SubtractByteOffset(T % source, UIntPtr byteOffset);
[System.CLSCompliant(false)]
public static ref T SubtractByteOffset<T>(ref T source, UIntPtr byteOffset) where T : allows ref struct;
public static ref T SubtractByteOffset<T>(ref T source, nuint byteOffset);
[System.CLSCompliant(false)]
public static ref T SubtractByteOffset<T>(ref T source, UIntPtr byteOffset);
[<System.CLSCompliant(false)>]
static member SubtractByteOffset : 'T * unativeint -> 'T
static member SubtractByteOffset : 'T * unativeint -> 'T
Public Shared Function SubtractByteOffset(Of T) (ByRef source As T, byteOffset As UIntPtr) As T
類型參數
- T
Managed 指標的專案型別。
參數
- source
- T
要減去位移的Managed指標。
- byteOffset
-
UIntPtr
nuint
unativeint
要減去的位移。
傳回
新的 Managed 指標,反映來源指標中指定位元組位移的減法。
- 屬性
備註
參數 byteOffset 是從指標減去 source 的位元組數目。 例如,假設類型為 的來源指標 ptrref int,呼叫Unsafe.SubtractByteOffset<int>(ref ptr, (nuint)20)會傳回新的指標,其位址點在 ptr 之前為 20 個字節。
如果 byteOffset 是計算值,而不是硬式編碼常值,呼叫端應該考慮整數溢位的可能性。 例如,在呼叫 中,呼叫 Unsafe.SubtractByteOffset<int>(ref ptr, a * b)端必須確定中繼值 a * b 不會溢位 的界限 UIntPtr。