G
Guest
Dear colleagues,
I have a collection which stores arrays of numbers.
I do the following to fill the elements of the collection:
Dim array1() As Integer = {1, 2, 3}
Dim array2() As Integer = {4, 5, 6}
Dim my_collection As New Collection
my_collection.Add(array1, “Variable1â€)
my_collection Add(my_collection.Item(“Variable1â€), “Variable2â€)
my_collection.Add(array2, “Variable3â€)
Dim array3() As Integer = my_collection.Item(“Variable1â€)
Dim array4() As Integer = my_collection.Item(“Variable3â€)
array3(0) = array4(0)
my_collection.Remove(“Variable1â€)
my_collection.Add(array3, “Variable1â€)
So I should get this:
Variable1 = [4 2 3]
Variable2 = [1 2 3]
Variable3 = [4 5 6]
But instead I get the following:
Variable1 = [4 2 3]
Variable2 = [4 2 3]
Variable3 = [4 5 6]
The value of Variable2 changes as well. And I do not want that.
Any advice in how to solve this problem?
Thanks in advance,
Emilia.
I have a collection which stores arrays of numbers.
I do the following to fill the elements of the collection:
Dim array1() As Integer = {1, 2, 3}
Dim array2() As Integer = {4, 5, 6}
Dim my_collection As New Collection
my_collection.Add(array1, “Variable1â€)
my_collection Add(my_collection.Item(“Variable1â€), “Variable2â€)
my_collection.Add(array2, “Variable3â€)
Dim array3() As Integer = my_collection.Item(“Variable1â€)
Dim array4() As Integer = my_collection.Item(“Variable3â€)
array3(0) = array4(0)
my_collection.Remove(“Variable1â€)
my_collection.Add(array3, “Variable1â€)
So I should get this:
Variable1 = [4 2 3]
Variable2 = [1 2 3]
Variable3 = [4 5 6]
But instead I get the following:
Variable1 = [4 2 3]
Variable2 = [4 2 3]
Variable3 = [4 5 6]
The value of Variable2 changes as well. And I do not want that.
Any advice in how to solve this problem?
Thanks in advance,
Emilia.