This method is used to compare two specified Decimal values.
Syntax: public static int Compare (decimal a1, decimal a2);
a1:This parameter specifies the first value to compare.
a2:This parameter specifies the second value to compare.
Return Value: It returns a signed number indicating the relative values of a1 & a2.
- If the value is less than zero, it means a1 is less than a2.
- If the value is greater than zero, it means a1 is greater than a2.
- If the value is zero, it means a1 is equal to a2.
Below programs illustrate the use of Decimal.Compare(Decimal, Decimal) Method
Example 1: When a1 is greater than a2.
The compare value is : 1
Example 2: When a1 is less than a2.
The compare value is : -1
Example 3: When a1 is equals to a2.
The compare value is : 0
- Difference between Method Overriding and Method Hiding in C#
- C# | Math.Exp() Method
- C# | ToUpper() Method
- Main Method in C#
- C# | Copy() Method
- C# | Math.Abs() Method | Set - 1
- C# | Method Overriding
- C# | IndexOfAny() Method
- DateTimeOffset.Add() Method in C#
- TimeSpan.Add() Method in C#
- C# | Math.Min() Method
- C# | Math.Max() Method
- Queue.Contains() Method in C#
- C# | Math.Sin() Method
- C# | Math.Cos() Method
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.