本文整理汇总了VB.NET中System.TimeSpan.Compare方法的典型用法代码示例。如果您正苦于以下问题:VB.NET TimeSpan.Compare方法的具体用法?VB.NET TimeSpan.Compare怎么用?VB.NET TimeSpan.Compare使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.TimeSpan
的用法示例。
在下文中一共展示了TimeSpan.Compare方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的VB.NET代码示例。
示例1: Example
Public Module Example
Public Sub Main()
' Define a time interval equal to 2 hours.
Dim baseInterval As New TimeSpan( 2, 0, 0)
' Define an array of time intervals to compare with
' the base interval.
Dim spans() As TimeSpan = { TimeSpan.FromSeconds(-2.5),
TimeSpan.FromMinutes(20),
TimeSpan.FromHours(1),
TimeSpan.FromMinutes(90),
baseInterval,
TimeSpan.FromDays(.5),
TimeSpan.FromDays(1) }
' Compare the time intervals.
For Each span In spans
Dim result As Integer = TimeSpan.Compare(baseInterval, span)
Console.WriteLine("{0} {1} {2} (Compare returns {3})",
baseInterval,
If(result = 1, ">", If(result = 0, "=", "<")),
span, result)
Next
End Sub
End Module
输出:
02:00:00 > -00:00:02.5000000 (Compare return 02:00:00 > 00:20:00 (Compare returns 1 02:00:00 > 01:00:00 (Compare returns 1 02:00:00 > 01:30:00 (Compare returns 1 02:00:00 = 02:00:00 (Compare returns 0 02:00:00 < 12:00:00 (Compare returns -1 02:00:00 < 1.00:00:00 (Compare returns -1