kimosavi
Active member
Hi,
I am trying to work with classes and variables and don't seem to understand some behavior that is going on.
first off the class
Usage and behavior (example code)
When I assign S2 = S1 all the values of S1 passes to S2 but also there is a "link" or bond between the two variables now.
if I change the values of S2 this automatically changes the values of S1!!
Why does this happen and how can I prevent it?
I just want to pass the variables values contained S1 to S2.
Thanks in advance!
I am trying to work with classes and variables and don't seem to understand some behavior that is going on.
first off the class
VB.NET:
Public Class csSession
Public ID As Integer
Public Name As String
End Class
Usage and behavior (example code)
VB.NET:
Dim S1 as new csSession
Dim S2 as new csSession
S1.ID = 1
S1.Name = "1st Session"
S2 = S1
S2.ID = 99
When I assign S2 = S1 all the values of S1 passes to S2 but also there is a "link" or bond between the two variables now.
if I change the values of S2 this automatically changes the values of S1!!
Why does this happen and how can I prevent it?
I just want to pass the variables values contained S1 to S2.
Thanks in advance!