Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

Decimal.LessThan Operator

Returns a value indicating whether a specified Decimal is less than another specified Decimal.

Namespace:  System
Assembly:  mscorlib (in mscorlib.dll)
public static bool operator <(
	decimal d1,
	decimal d2
)

Parameters

d1
Type: System.Decimal
A Decimal.
d2
Type: System.Decimal
A Decimal.

Return Value

Type: System.Boolean
true if d1 is less than d2; otherwise, false.

The following code example compares several Decimal values to a reference Decimal value using the Less Than operator.


// Example of the decimal relational operators.
using System;

class Example
{
   const string dataFmt = "{0,43}    {1}";

   // Compare decimal parameters, and display them with the results.
   static void CompareDecimals(System.Windows.Controls.TextBlock outputBlock, decimal Left, decimal Right,
       string RightText)
   {
      outputBlock.Text += "\n";
      outputBlock.Text += String.Format(dataFmt, "Right: " + RightText, Right) + "\n";
      outputBlock.Text += String.Format(dataFmt, "Left == Right", Left == Right) + "\n";
      outputBlock.Text += String.Format(dataFmt, "Left >  Right", Left > Right) + "\n";
      outputBlock.Text += String.Format(dataFmt, "Left >= Right", Left >= Right) + "\n";
      outputBlock.Text += String.Format(dataFmt, "Left != Right", Left != Right) + "\n";
      outputBlock.Text += String.Format(dataFmt, "Left <  Right", Left < Right) + "\n";
      outputBlock.Text += String.Format(dataFmt, "Left <= Right", Left <= Right) + "\n";
   }

   public static void Demo(System.Windows.Controls.TextBlock outputBlock)
   {
      decimal Left = new decimal(123.456);

      outputBlock.Text += 
          "This example of the decimal relational operators " +
          "generates the \nfollowing output. It creates several " +
          "different decimal values \nand compares them with " +
          "the following reference value.\n" + "\n";
      outputBlock.Text += String.Format(dataFmt,
          "Left: decimal( 123.456 )", Left) + "\n";

      // Create objects to compare with a 2-hour decimal.
      CompareDecimals(outputBlock, Left, new decimal(1.23456E+2),
          "decimal( 1.23456E+2 )");
      CompareDecimals(outputBlock, Left, new decimal(123.4567),
          "decimal( 123.4567 )");
      CompareDecimals(outputBlock, Left, new decimal(123.4553),
          "decimal( 123.4553 )");
      CompareDecimals(outputBlock, Left, new decimal(123456000, 0, 0, false, 6),
          "decimal( 123456000, 0, 0, false, 6 )");
   }
}

/*
This example of the decimal relational operators generates the
following output. It creates several different decimal values
and compares them with the following reference value.

                   Left: decimal( 123.456 )    123.456

               Right: decimal( 1.23456E+2 )    123.456
                              Left == Right    True
                              Left >  Right    False
                              Left >= Right    True
                              Left != Right    False
                              Left <  Right    False
                              Left <= Right    True

                 Right: decimal( 123.4567 )    123.4567
                              Left == Right    False
                              Left >  Right    False
                              Left >= Right    False
                              Left != Right    True
                              Left <  Right    True
                              Left <= Right    True

                 Right: decimal( 123.4553 )    123.4553
                              Left == Right    False
                              Left >  Right    True
                              Left >= Right    True
                              Left != Right    True
                              Left <  Right    False
                              Left <= Right    False

Right: decimal( 123456000, 0, 0, false, 6 )    123.456000
                              Left == Right    True
                              Left >  Right    False
                              Left >= Right    True
                              Left != Right    False
                              Left <  Right    False
                              Left <= Right    True
*/


Silverlight

Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

XNA Framework

Supported in: Xbox 360, Windows Phone OS 7.0

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.