Decimal.Increment(Decimal) Operador

Definición

Incrementa en 1 el operando Decimal.Increments the Decimal operand by 1.

public:
 static System::Decimal operator ++(System::Decimal d);
public static decimal operator ++ (decimal d);
static member op_Increment : decimal -> decimal
Public Shared op_Increment (d As Decimal) As Decimal

Parámetros

d
Decimal

Valor que se va a aumentar.The value to increment.

Devoluciones

Valor de d incrementado en 1.The value of d incremented by 1.

Excepciones

El valor devuelto es menor que MinValue o mayor que MaxValue.The return value is less than MinValue or greater than MaxValue.

Comentarios

El método Increment define la operación del operador de incremento para Decimal valores.The Increment method defines the operation of the increment operator for Decimal values. Permite el código como el siguiente:It enables code such as the following:

using System;

public class Example
{
   public static void Main()
   {
      Decimal number = 1079.8m;
      Console.WriteLine("Original value:    {0:N}", number);
      Console.WriteLine("Incremented value: {0:N}", ++number); 
   }
}
// The example displays the following output:
//       Original value:    1,079.80
//       Incremented value: 1,080.80

Algunos lenguajes (como Visual Basic) que carecen de un operador de incremento pueden llamar al método Increment directamente, como se muestra en el ejemplo siguiente.Some languages (such as Visual Basic) that lack an increment operator can call the Increment method directly, as the following example shows.

Module Example
   Public Sub Main()
      Dim number As Decimal = 1079.8d
      Console.WriteLine("Original value:    {0:N}", number)
      Console.WriteLine("Incremented value: {0:N}", Decimal.op_Increment(number))
   End Sub
End Module
' The example displays the following output:
'       Original value:    1,079.80
'       Incremented value: 1,080.80

Si su lenguaje no admite operadores personalizados, llame al método Add en su lugar, como se muestra en el ejemplo siguiente.If your language does not support custom operators, call the Add method instead, as the following example shows.

using System;

public class Example
{
   public static void Main()
   {
      Decimal number = 1079.8m;
      Console.WriteLine("Original value:    {0:N}", number);
      Console.WriteLine("Incremented value: {0:N}", Decimal.Add(number, 1)); 
   }
}
// The example displays the following output:
//       Original value:    1,079.80
//       Incremented value: 1,080.80
Module Example
   Public Sub Main()
      Dim number As Decimal = 1079.8d
      Console.WriteLine("Original value:    {0:N}", number)
      Console.WriteLine("Incremented value: {0:N}", Decimal.Add(number, 1))
   End Sub
End Module
' The example displays the following output:
'       Original value:    1,079.80
'       Incremented value: 1,080.80

Se aplica a

Consulte también: