当前位置: 首页>>代码示例>>VB.NET>>正文


VB.NET Tuple<T1>.IStructuralComparable.CompareTo方法代码示例

本文整理汇总了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
开发者ID:VB.NET开发者,项目名称:System,代码行数:43,代码来源:Tuple.IStructuralComparable.CompareTo

输出:

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


注:本文中的System.Tuple<T1>.IStructuralComparable.CompareTo方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。