本文整理汇总了VB.NET中System.Collections.IStructuralEquatable.Equals方法的典型用法代码示例。如果您正苦于以下问题:VB.NET IStructuralEquatable.Equals方法的具体用法?VB.NET IStructuralEquatable.Equals怎么用?VB.NET IStructuralEquatable.Equals使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Collections.IStructuralEquatable
的用法示例。
在下文中一共展示了IStructuralEquatable.Equals方法的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
示例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
输出:
True True True False