UIntPtr.Subtraction(UIntPtr, Int32) UIntPtr.Subtraction(UIntPtr, Int32) UIntPtr.Subtraction(UIntPtr, Int32) UIntPtr.Subtraction(UIntPtr, Int32) Operator

定義

符号なしポインターの値からオフセットを減算します。Subtracts an offset from the value of an unsigned pointer.

public:
 static UIntPtr operator -(UIntPtr pointer, int offset);
public static UIntPtr operator - (UIntPtr pointer, int offset);
static member ( - ) : unativeint * int -> unativeint
Public Shared Operator - (pointer As UIntPtr, offset As Integer) As UIntPtr

パラメーター

pointer
UIntPtr UIntPtr UIntPtr UIntPtr

オフセットを減算する符号なしポインター。The unsigned pointer to subtract the offset from.

offset
Int32 Int32 Int32 Int32

減算するオフセット。The offset to subtract.

戻り値

offset からの pointer の減算が反映された新しい符号なしポインター。A new unsigned pointer that reflects the subtraction of offset from pointer.

注釈

Subtractionメソッド定義の減算演算UIntPtrオブジェクト。The Subtraction method defines the subtraction operation for UIntPtr objects. コードは、次のようにできます。It enables code such as the following.

int[] arr = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
UIntPtr ptr = (UIntPtr) arr[arr.GetUpperBound(0)];
for (int ctr = 0; ctr <= arr.GetUpperBound(0); ctr++)
{
   UIntPtr newPtr = ptr - ctr;
   Console.Write("{0}   ", newPtr);
}
Dim arr() As Integer = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10}
Dim ptr As UIntPtr = CType(arr(arr.GetUpperBound(0)), UIntPtr)
For ctr As Integer= 0 To arr.GetUpperBound(0)
   Dim newPtr As UIntPtr = UIntPtr.Subtract(ptr, ctr)
   Console.Write("{0}   ", newPtr)
Next

カスタム演算子をサポートしない言語を呼び出すことができます、Subtractメソッド代わりにします。Languages that do not support custom operators can call the Subtract method instead.

減算演算は、指定したプラットフォームのポインターとして表すため、結果が小さすぎる場合、例外はスローされません。The subtraction operation does not throw an exception if the result is too small to represent as a pointer on the specified platform. 代わりに、unchecked コンテキストで実行します。Instead, it is performed in an unchecked context.

適用対象

こちらもご覧ください