本文整理匯總了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