Decimal.LessThan(Decimal, Decimal) 연산자

정의

지정된 Decimal이 지정된 다른 Decimal보다 작은지 여부를 나타내는 값을 반환합니다.

public:
 static bool operator <(System::Decimal d1, System::Decimal d2);
public static bool operator < (decimal d1, decimal d2);
static member ( < ) : decimal * decimal -> bool
Public Shared Operator < (d1 As Decimal, d2 As Decimal) As Boolean

매개 변수

d1
Decimal

비교할 첫 번째 값입니다.

d2
Decimal

비교할 두 번째 값입니다.

반환

Boolean

d1d2보다 작으면 true이고, 그렇지 않으면 false입니다.

설명

LessThan메서드는 값에 대 한 보다 작음 연산자의 연산을 정의 합니다 Decimal . 다음과 같은 코드를 사용할 수 있습니다.

using System;

public class Example
{
   public static void Main()
   {
      Decimal number1 = 16354.0699m;
      Decimal number2 = 16354.0695m;
      Console.WriteLine("{0} < {1}: {2}", number1,
                        number2, number1 < number2);

      number1 = Decimal.Round(number1, 2);
      number2 = Decimal.Round(number2, 2);
      Console.WriteLine("{0} < {1}: {2}", number1,
                        number2, number1 < number2);
   }
}
// The example displays the following output:
//       16354.0699 < 16354.0695: False
//       16354.07 < 16354.07: False
Module Example
   Public Sub Main()
      Dim number1 As Decimal = 16354.0699d
      Dim number2 As Decimal = 16354.0695d
      Console.WriteLine("{0} < {1}: {2}", number1, 
                        number2, number1 < number2)

      number1 = Decimal.Round(number1, 2)
      number2 = Decimal.Round(number2, 2)
      Console.WriteLine("{0} < {1}: {2}", number1, 
                        number2, number1 < number2)
   End Sub
End Module
' The example displays the following output:
'       16354.0699 < 16354.0695: False
'       16354.07 < 16354.07: False

사용자 지정 연산자를 지원 하지 않는 언어는 대신 메서드를 호출할 수 있습니다 Compare . 또한 LessThan 다음 예제와 같이 메서드를 직접 호출할 수 있습니다.

Module Example
   Public Sub Main()
      Dim number1 As Decimal = 16354.0699d
      Dim number2 As Decimal = 16354.0695d
      Console.WriteLine("{0} < {1}: {2}", number1, number2, 
                        Decimal.op_LessThan(number1, number2))

      number1 = Decimal.Round(number1, 2)
      number2 = Decimal.Round(number2, 2)
      Console.WriteLine("{0} < {1}: {2}", number1, number2, 
                        Decimal.op_LessThan(number1, number2))
   End Sub
End Module
' The example displays the following output:
'       16354.0699 < 16354.0695: False
'       16354.07 < 16354.07: False

이 연산자에 대 한 해당 메서드는 Decimal.Compare(Decimal, Decimal)

적용 대상

추가 정보