ValueType.Equals Method Indicates whether this instance and a specified object are equal. : Structure « Language Basics « VB.Net






ValueType.Equals Method Indicates whether this instance and a specified object are equal.

 

Public Structure Complex
   Private m_Re As Double
   Private m_Im As Double

   Public Overloads Function Equals(ob As Object) As Boolean
      If TypeOf ob Is Complex Then
         Dim c As Complex = CType(ob, Complex)
         Return m_Re = c.m_Re And m_Im = c.m_Im
      Else
         Return False
      End If
   End Function


   Public Overloads Function GetHashCode() As Integer
      Return m_Re.GetHashCode() ^ m_Im.GetHashCode()
   End Function

    
    
End Structure

Class Test
    Public Shared Sub Main()
    End Sub
End Class

   
  








Related examples in the same category

1.Structure Variable assignment
2.ToString Method for Structure data typeToString Method for Structure data type
3.Structure overrides ToString method
4.Structure with Constructor
5.Store Structure into a Collection
6.Compare Structure and ClassCompare Structure and Class
7.Pass Structure into a FunctionPass Structure into a Function
8.Simple Structure DemoSimple Structure Demo