JCreationsInc
Freshman
Welll hello again it is I mogore the great with an array problem for you people to digest. I have searched far and wide in the ever confusing world of the VS.Net Combined Help to no avail. And it is now that I bow down to behold the true power of the dotnetforums! Anyways heres what is happening.
I have and array of type Object, and I need to make an exhact copy of it to work on without disturbing the original array (and this is where I run into a brick wall at full speed) I am using the Array.Copy function and it seems to work except when I alter the array, the origianl copy that I do not want altered gets altered. Here is my code:
According to the help, a reference type array is being copied instead of a value type array(which is what I want) so when I alter the "ItemsClone" array it alters the original "Items" array(which is what I dont want)
Here is a portions from the help file:
"If sourceArray and destinationArray are both reference-type arrays or are both arrays of type Object, a shallow copy is performed. A shallow copy of an Array is a new Array containing references to the same elements as the original Array. The elements themselves or anything referenced by the elements are not copied. In contrast, a deep copy of an Array copies the elements and everything directly or indirectly "
So... Does anyone know how to create a "Deep" copy? or do I need to use a another Type for my array instead of Object?
I have and array of type Object, and I need to make an exhact copy of it to work on without disturbing the original array (and this is where I run into a brick wall at full speed) I am using the Array.Copy function and it seems to work except when I alter the array, the origianl copy that I do not want altered gets altered. Here is my code:
Visual Basic:
'The items array mentioned is a multi-dimensional object array
'with each element initialized to a different class that holds
'properties of items such as controls and images
'Copy our items array into our working array
Dim ItemsClone(Items.GetUpperBound(0)) As Object
Items.Copy(Items, ItemsClone, Items.GetUpperBound(0))
According to the help, a reference type array is being copied instead of a value type array(which is what I want) so when I alter the "ItemsClone" array it alters the original "Items" array(which is what I dont want)
Here is a portions from the help file:
"If sourceArray and destinationArray are both reference-type arrays or are both arrays of type Object, a shallow copy is performed. A shallow copy of an Array is a new Array containing references to the same elements as the original Array. The elements themselves or anything referenced by the elements are not copied. In contrast, a deep copy of an Array copies the elements and everything directly or indirectly "
So... Does anyone know how to create a "Deep" copy? or do I need to use a another Type for my array instead of Object?