Decimal.Inequality(Decimal, Decimal) 연산자

정의

Decimal 개체의 값이 서로 다른지 여부를 나타내는 값을 반환합니다.

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

매개 변수

d1
Decimal

비교할 첫 번째 값입니다.

d2
Decimal

비교할 두 번째 값입니다.

반품

같으면 /&이고 , 그렇지 않으면 .입니다.

구현

설명

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

using System;

public class Example
{
   public static void Main()
   {
      Decimal number1 = 16354.0695m;
      Decimal number2 = 16354.0699m;
      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.0695 <> 16354.0699: True
//       16354.07 <> 16354.07: False
open System

let number1 = 16354.0695m
let number2 = 16354.0699m
printfn $"{number1} <> {number2}: {number1 <> number2}"

let rounded1 = Decimal.Round(number1, 2)
let rounded2 = Decimal.Round(number2, 2)
printfn $"{rounded1} <> {rounded2}: {rounded1 <> rounded2}"

// The example displays the following output:
//       16354.0695 <> 16354.0699: True
//       16354.07 <> 16354.07: False
Module Example
   Public Sub Main()
      Dim number1 As Decimal = 16354.0695d
      Dim number2 As Decimal = 16354.0699d
      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.0695 <> 16354.0699: True
'       16354.07 <> 16354.07: False

사용 중인 언어가 사용자 지정 연산자를 지원하지 않는 경우 다음 기술 중 하나를 사용하여 같지 않음을 테스트할 수 있습니다.

  • CompareDecimal 값 간의 관계를 나타내는 메서드를 호출합니다.
  • 메서드를 Equals 호출하고 해당 값을 반전합니다.

이 연산자에 해당하는 메서드는 다음과 같습니다. Decimal.Compare(Decimal, Decimal)

적용 대상

추가 정보