本文整理匯總了C#中System.Decimal.Compare方法的典型用法代碼示例。如果您正苦於以下問題:C# Decimal.Compare方法的具體用法?C# Decimal.Compare怎麽用?C# Decimal.Compare使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.Decimal
的用法示例。
在下文中一共展示了Decimal.Compare方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: Main
//引入命名空間
using System;
public enum Relationship
{ LessThan = -1, Equals = 0, GreaterThan = 1 }
public class Example
{
public static void Main()
{
decimal value1 = Decimal.MaxValue;
decimal value2 = value1 - .01m;
Console.WriteLine("{0} {2} {1}", value1, value2,
(Relationship) Decimal.Compare(value1, value2));
value2 = value1 / 12m - .1m;
value1 = value1 / 12m;
Console.WriteLine("{0} {2} {1}", value1, value2,
(Relationship) Decimal.Compare(value1, value2));
value1 = value1 - .2m;
value2 = value2 + .1m;
Console.WriteLine("{0} {2} {1}", value1, value2,
(Relationship) Decimal.Compare(value1, value2));
}
}
輸出:
79228162514264337593543950335 Equals 79228162514264337593543950335 6602346876188694799461995861.2 GreaterThan 6602346876188694799461995861.1 6602346876188694799461995861.0 LessThan 6602346876188694799461995861.2