本文整理匯總了VB.NET中System.Decimal.Compare方法的典型用法代碼示例。如果您正苦於以下問題:VB.NET Decimal.Compare方法的具體用法?VB.NET Decimal.Compare怎麽用?VB.NET Decimal.Compare使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.Decimal
的用法示例。
在下文中一共展示了Decimal.Compare方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的VB.NET代碼示例。
示例1: Example
Public Enum Relationship As Integer
LessThan = -1
Equals = 0
GreaterThan = 1
End Enum
Module Example
Public Sub Main()
Dim value1 As Decimal = Decimal.MaxValue
Dim value2 As Decimal = value1 - .01d
Console.WriteLine("{0} {2} {1}", value1, value2,
CType(Decimal.Compare(value1, value2), Relationship))
value2 = value1 / 12d - .1d
value1 = value1 / 12d
Console.WriteLine("{0} {2} {1}", value1, value2,
CType(Decimal.Compare(value1, value2), Relationship))
value1 = value1 - .2d
value2 = value2 + .1d
Console.WriteLine("{0} {2} {1}", value1, value2,
CType(Decimal.Compare(value1, value2), Relationship))
End Sub
End Module
輸出:
79228162514264337593543950335 Equals 79228162514264337593543950335 6602346876188694799461995861.2 GreaterThan 6602346876188694799461995861.1 6602346876188694799461995861.0 LessThan 6602346876188694799461995861.2
示例2: Test
public class Test
public Shared Sub Main
Dim D1, D2 As Decimal
D1 = 10
D2 = 5.7
Console.WriteLine(Decimal.Compare(D1, D2))
End Sub
End class