本文整理匯總了VB.NET中System.Tuple<T1>.IStructuralComparable.CompareTo方法的典型用法代碼示例。如果您正苦於以下問題:VB.NET Tuple<T1>.IStructuralComparable.CompareTo方法的具體用法?VB.NET Tuple<T1>.IStructuralComparable.CompareTo怎麽用?VB.NET Tuple<T1>.IStructuralComparable.CompareTo使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。
在下文中一共展示了Tuple<T1>.IStructuralComparable.CompareTo方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的VB.NET代碼示例。
示例1: Main
' 導入命名空間
Imports System.Collections.Generic
Public Class DescendingComparer(Of T) : Implements IComparer(Of T)
Public Function Compare(ByVal x As T, ByVal y As T) As Integer Implements IComparer(Of T).Compare
Return -1 * Comparer(Of T).Default.Compare(x, y)
End Function
End Class
Module Example
Sub Main()
Dim values() = { Tuple.Create(13.54),
Tuple.Create(Double.NaN),
Tuple.Create(-189.42993),
Tuple.Create(Double.PositiveInfinity),
Tuple.Create(Double.Epsilon),
Tuple.Create(1.934E-17),
Tuple.Create(Double.NegativeInfinity),
Tuple.Create(-0.000000000003588),
Nothing}
Console.WriteLine("The values in unsorted order:")
For Each value As Tuple(Of Double) In values
If value IsNot Nothing Then
Console.WriteLine(" {0}", value.Item1)
Else
Console.WriteLine(" <null>")
End If
Next
Console.WriteLine()
Array.Sort(values, New DescendingComparer(Of Tuple(Of Double)))
Console.WriteLine("The values sorted in descending order:")
For Each value As Tuple(Of Double) In values
If value IsNot Nothing Then
Console.WriteLine(" {0}", value.Item1)
Else
Console.WriteLine(" <null>")
End If
Next
End Sub
End Module
輸出:
The values in unsorted order: 13.54 NaN -189.42993 Infinity 4.94065645841247E-324 1.934E-17 -Infinity -3.588E-12 The values sorted in descending order: Infinity 13.54 1.934E-17 4.94065645841247E-324 -3.588E-12 -189.42993 -Infinity NaN