let say i have that
Structure myStruct Public myPoint As Point Public myBool As Boolean End Structure
how to I make a copy / clone of that structure?
I fixed that issue now, example of the code I was using:
Dim myStruct(1) As myStruct myStruct(0).myPoint = New Point(10, 10) myStruct(0).myBool = True Dim myCopy(1) As myStruct myCopy = myStruct myCopy(0).myBool = False myCopy(0).myPoint = New Point(11, 11)
with that, both variable was changed
I had to do
myCopy = CType(myStruct.Clone, myStruct())
and another question, if that structure is used, let say, 10,000 times, should I created a class instead?
You’re looking at 12 bytes per structure, so passing it around as a struct is cheaper than creating a word-sized reference to it on heap (in other words, using a class)
If you need to access all 10,000 at once, creating an array of them will happen on the heap even if they are structs.
Copying the struct is as easy as creating declaring another struct of the same type and assigning the first to the second.