本文整理汇总了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