Adagio
Well-known member
- Joined
- Dec 12, 2005
- Messages
- 162
- Programming Experience
- Beginner
I have the following class:
When I do the following:
Create a variable of Class1, sets both dates, creates another variable using the Copy function (copying the first variable), then sets the dates to something else
The problem (as you would probably have guessed) is that when I set the dates for the second variable, the dates for the first variable will also be set
The problem seems to be with arrays/list of only. Does anybody here know how to fix the problem?
VB.NET:
Public Class Class1
Private someDates(1) As Date
Public Property SomeDate1() As Date
Get
Return someDates(0)
End Get
Set(ByVal value As Date)
someDates(0) = value
End Set
End Property
Public Property SomeDate2() As Date
Get
Return someDates(1)
End Get
Set(ByVal value As Date)
someDates(1) = value
End Set
End Property
Public Shared Function Copy(ByVal c As Class1) As Class1
Return DirectCast(c.MemberwiseClone, Class1)
End Function
End Class
When I do the following:
Create a variable of Class1, sets both dates, creates another variable using the Copy function (copying the first variable), then sets the dates to something else
The problem (as you would probably have guessed) is that when I set the dates for the second variable, the dates for the first variable will also be set
The problem seems to be with arrays/list of only. Does anybody here know how to fix the problem?