UIntPtr.Addition(UIntPtr, Int32) 演算子
定義
符号なしポインターの値にオフセットを加算します。Adds an offset to 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
オフセットを加算する符号なしポインター。The unsigned pointer to add the offset to.
- offset
- Int32
加算するオフセット。The offset to add.
戻り値
offset
への pointer
の加算が反映された新しい符号なしポインター。A new unsigned pointer that reflects the addition of offset
to pointer
.
注釈
メソッドは、 Addition オブジェクトの加算演算を定義し UIntPtr ます。The Addition method defines the addition 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[0];
for (int ctr = 0; ctr < arr.Length; ctr++)
{
UIntPtr newPtr = ptr + ctr;
Console.WriteLine(newPtr);
}
Dim arr() As Integer = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }
Dim ptr = CType(arr(0), UIntPtr)
For ctr As Integer = 0 To arr.Length - 1
Dim newPtr As UIntPtr = ptr + ctr
Console.WriteLine(newPtr)
Next
カスタム演算子をサポートしない言語では、代わりにメソッドを呼び出すことができ Add ます。Languages that do not support custom operators can call the Add method instead.
加算演算では、結果が大きすぎて指定されたプラットフォーム上のポインターとして表現できない場合、例外はスローされません。The addition operation does not throw an exception if the result is too large to represent as a pointer on the specified platform. 代わりに、unchecked コンテキストで実行されます。Instead, it is performed in an unchecked context.
この演算子の同等のメソッドは UIntPtr.Add(UIntPtr, Int32) です。The equivalent method for this operator is UIntPtr.Add(UIntPtr, Int32).