Decimal.LessThanOrEqual(Decimal, Decimal) Opérateur

Définition

Retourne une valeur indiquant si un Decimal spécifié est inférieur ou égal à un autre Decimal spécifié.

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

Paramètres

d1
Decimal

Première valeur à comparer.

d2
Decimal

Deuxième valeur à comparer.

Retours

true si d1 est inférieur ou égal à d2 ; sinon, false.

Implémente

Remarques

La LessThanOrEqual méthode définit l’opération de l’opérateur inférieur ou égal à pour les Decimal valeurs. Il active le code tel que le suivant :

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: True
open System

let number1 = 16354.0699m
let number2 = 16354.0695m
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.0699 <= 16354.0695: False
//       16354.07 <= 16354.07: True
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: True

Les langues qui ne prennent pas en charge les opérateurs personnalisés peuvent appeler la méthode à la Compare place. Ils peuvent également être en mesure d’appeler la LessThanOrEqual méthode directement, comme le montre l’exemple suivant.

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_LessThanOrEqual(number1, number2))

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

La méthode équivalente pour cet opérateur est Decimal.Compare(Decimal, Decimal)

S’applique à

Voir aussi