Decimal.Increment(Decimal) 演算子

定義

Decimal オペランドを 1 だけインクリメントします。

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

パラメーター

d
Decimal

インクリメントする値。

戻り値

1 だけインクリメントした d の値。

実装

例外

戻り値が Decimal.MinValue より小さいか、 Decimal.MaxValue より大きい。

注釈

メソッドは Increment 、値のインクリメント演算子の操作を Decimal 定義します。 これにより、次のようなコードが有効になります。

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

インクリメント演算子がない一部の言語 (Visual Basic など) では、次の例に示すように、 メソッドを直接呼び出 Increment すことができます。

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

言語でカスタム演算子がサポートされていない場合は、次の Add 例に示すように、代わりに メソッドを呼び出します。

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

適用対象

こちらもご覧ください