本文整理汇总了VB.NET中System.Collections.IStructuralEquatable接口的典型用法代码示例。如果您正苦于以下问题:VB.NET IStructuralEquatable接口的具体用法?VB.NET IStructuralEquatable怎么用?VB.NET IStructuralEquatable使用的例子?那么恭喜您, 这里精选的接口代码示例或许可以为您提供帮助。
在下文中一共展示了IStructuralEquatable接口的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的VB.NET代码示例。
示例1: Equals
' 导入命名空间
Imports System.Collections
Imports System.Collections.Generic
Public Class NanComparer : Implements IEqualityComparer
Public Overloads Function Equals(x As Object, y As Object) As Boolean _
Implements IEqualityComparer.Equals
If TypeOf x Is Single Then
Return CSng(x) = CSng(y)
ElseIf TypeOf x Is Double Then
Return CDbl(x) = CDbl(y)
Else
Return EqualityComparer(Of Object).Default.Equals(x, y)
End If
End Function
Public Overloads Function GetHashCode(obj As Object) As Integer _
Implements IEqualityComparer.GetHashCode
Return EqualityComparer(Of Object).Default.GetHashCode(obj)
End Function
End Class
开发者ID:VB.NET开发者,项目名称:System.Collections,代码行数:21,代码来源:IStructuralEquatable
示例2: Example
Module Example
Public Sub Main()
Dim t1 = Tuple.Create(12.3, Double.NaN, 16.4)
Dim t2 = Tuple.Create(12.3, Double.NaN, 16.4)
' Call default Equals method.
Console.WriteLine(t1.Equals(t2))
Dim equ As IStructuralEquatable = t1
' Call IStructuralEquatable.Equals using default comparer.
Console.WriteLine(equ.Equals(t2, EqualityComparer(Of Object).Default))
' Call IStructuralEquatable.Equals using
' StructuralComparisons.StructuralEqualityComparer.
Console.WriteLine(equ.Equals(t2,
StructuralComparisons.StructuralEqualityComparer))
' Call IStructuralEquatable.Equals using custom comparer.
Console.WriteLine(equ.Equals(t2, New NanComparer))
End Sub
End Module
开发者ID:VB.NET开发者,项目名称:System.Collections,代码行数:21,代码来源:IStructuralEquatable 输出:
True
True
True
False
注:本文中的System.Collections.IStructuralEquatable接口示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论