Posted by: Sourav | September 4, 2016

Override equals method in VB,VB teacher Sourav,Kolkata 09748184075

Option Strict On
Option Explicit On
Imports System

Module Module1

Sub Main()
Dim c1 As customer = New customer
c1.manipulatefirstname = “Sourav”
c1.manipulatelastname = “Bhattacharya”
Dim c2 As customer = New customer
c2.manipulatefirstname = “Sourav”
c2.manipulatelastname = “Bhattacharya”

End Sub

End Module
Public Class customer
Private firstname As String
Private lastname As String
Public Property manipulatefirstname As String
Return Me.firstname

End Get
Set(ByVal firstname As String)
Me.firstname = firstname

End Set

End Property
Public Property manipulatelastname As String
Return Me.lastname

End Get
Set(ByVal lastname As String)
Me.lastname = lastname

End Set

End Property
Public Overrides Function Equals(ByVal obj As Object) As Boolean
If IsNothing(obj) Then
Return False
End If
If Not TypeOf obj Is customer Then

Return False

End If
‘If TypeName(obj) = “customer” Then
‘    Return False
‘End If

Return Me.firstname = DirectCast(obj, customer).firstname And Me.lastname = DirectCast(obj, customer).lastname

End Function
End Class


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s


%d bloggers like this: