영어로 읽기

다음을 통해 공유


Decimal.Decrement(Decimal) 연산자

정의

Decimal 피연산자를 1씩 감소시킵니다.

public static decimal operator --(decimal d);

매개 변수

d
Decimal

감소시킬 값입니다.

반환

1씩 감소된 d의 값입니다.

구현

예외

반환 값이 Decimal.MinValue 보다 작거나 Decimal.MaxValue보다 큽니다.

설명

메서드는 Decrement 값에 대한 감소 연산자의 연산을 Decimal 정의합니다. 다음과 같은 코드를 사용하도록 설정합니다.

using System;

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

증분 연산자가 없는 일부 언어(예: Visual Basic)는 다음 예제와 같이 메서드를 직접 호출 Decrement 할 수 있습니다.

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

언어가 사용자 지정 연산자를 지원하지 않는 경우 다음 예제와 같이 메서드를 대신 호출 Subtract 합니다.

using System;

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

적용 대상

제품 버전
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 2.0, 2.1
UWP 10.0

추가 정보