Decimal.Increment(Decimal) Operátor
Definíció
Fontos
Egyes információk olyan, kiadás előtti termékekre vonatkoznak, amelyek a kiadásig még jelentősen módosulhatnak. A Microsoft nem vállal kifejezett vagy törvényi garanciát az itt megjelenő információért.
1-zel növeli az Decimal operandust.
public:
static System::Decimal operator ++(System::Decimal d);
public:
static System::Decimal operator ++(System::Decimal d) = System::Numerics::IIncrementOperators<System::Decimal>::op_Increment;
public static decimal operator ++(decimal d);
static member op_Increment : decimal -> decimal
Public Shared op_Increment (d As Decimal) As Decimal
Paraméterek
- d
- Decimal
A növekményes érték.
Válaszok
A növekmény értéke d 1-zel.
Megvalósítás
Kivételek
A visszatérési érték kisebb, mint a Decimal.MinValue vagy nagyobb, mint a Decimal.MaxValue.
Megjegyzések
A Increment metódus az értékek növekményes operátorának Decimal működését határozza meg. Engedélyezi a következő kódokat:
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
open System
let number = 1079.8m
printfn $"Original value: {number:N}"
printfn $"Incremented value: {Decimal.op_Increment number:N}"
// The example displays the following output:
// Original value: 1,079.80
// Incremented value: 1,080.80
Egyes nyelvek (például Visual Basic), amelyek nem rendelkeznek növekményes operátorral, közvetlenül meghívhatják a Increment metódust, ahogy az alábbi példa is mutatja.
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
Ha a nyelv nem támogatja az egyéni operátorokat, hívja inkább a Add metódust az alábbi példában látható módon.
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
open System
let number = 1079.8m
printfn $"Original value: {number:N}"
printfn $"Incremented value: {Decimal.Add(number, 1):N}"
// 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