UIntPtr.Subtraction(UIntPtr, Int32) Operador
Definición
Resta un desplazamiento del valor de un puntero sin signo.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
Parámetros
- pointer
- UIntPtr
Puntero sin signo del que se va a restar el desplazamiento.The unsigned pointer to subtract the offset from.
- offset
- Int32
Desplazamiento que se va a restar.The offset to subtract.
Devoluciones
Nuevo puntero sin signo que es el resultado de restar offset
de pointer
.A new unsigned pointer that reflects the subtraction of offset
from pointer
.
Comentarios
El Subtraction método define la operación de resta de UIntPtr objetos.The Subtraction method defines the subtraction operation for UIntPtr objects. Permite el código como el siguiente.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
Los lenguajes que no admiten operadores personalizados pueden llamar al Subtract método en su lugar.Languages that do not support custom operators can call the Subtract method instead.
La operación de resta no inicia una excepción si el resultado es demasiado pequeño para representarse como un puntero en la plataforma especificada.The subtraction operation does not throw an exception if the result is too small to represent as a pointer on the specified platform. En su lugar, se realiza en un contexto no comprobado.Instead, it is performed in an unchecked context.