D
DraguVaso
Hi,
I have 2 instances of a user-defined class. When I do a cls2 = cls1, and I
change a property of cls2, this property is also changed in my cls1!!
Does anybody know what the reason of this is? and how I can prevent it?
Thanks,
Pieter
I'm using VB.NET 2003.
This is my sample code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim cls1 As New clsMyClass
Dim cls2 As clsMyClass
cls2 = Nothing
cls2 = cls1
MessageBox.Show(cls1.Icon Is Nothing)
Dim bmp As New Bitmap(20, 20, Imaging.PixelFormat.Format32bppPArgb)
cls2.Icon = bmp
MessageBox.Show(cls1.Icon Is Nothing)
End Sub
Public Class clsMyClass
Private m_Icon As Bitmap
Public Property Icon() As Bitmap
Get
Return m_Icon
End Get
Set(ByVal Value As Bitmap)
m_Icon = Value
End Set
End Property
End Class
I have 2 instances of a user-defined class. When I do a cls2 = cls1, and I
change a property of cls2, this property is also changed in my cls1!!
Does anybody know what the reason of this is? and how I can prevent it?
Thanks,
Pieter
I'm using VB.NET 2003.
This is my sample code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim cls1 As New clsMyClass
Dim cls2 As clsMyClass
cls2 = Nothing
cls2 = cls1
MessageBox.Show(cls1.Icon Is Nothing)
Dim bmp As New Bitmap(20, 20, Imaging.PixelFormat.Format32bppPArgb)
cls2.Icon = bmp
MessageBox.Show(cls1.Icon Is Nothing)
End Sub
Public Class clsMyClass
Private m_Icon As Bitmap
Public Property Icon() As Bitmap
Get
Return m_Icon
End Get
Set(ByVal Value As Bitmap)
m_Icon = Value
End Set
End Property
End Class