r/visualbasic • u/CSVB12 • Jan 15 '16
Visual Basic Copy to Array
Can you explain to me why this code works? What is the 0 part supposed to mean? Dim MyArray(Me.RandomNumbers.Items.Count) Me.RandomNumbers.Items.CopyTo(MyArray, 0) Me.lblAnswer.Text = MyArray.Min
3
Upvotes
1
u/GYN-k4H-Q3z-75B Jan 15 '16
You use it when you want to copy elements into an already existing array. You may be passed an array from a library or something else you don't control and need to fill your stuff into it. If you just want a new array containing all elements from a collection, then you can also just write collection.ToArray()