CopyTo method is used to copy the array elements beginning at the middle of the array.
Imports System
Imports System.Collections.Generic
Module Example
Sub Main
Dim numbers As New Queue(Of String)
numbers.Enqueue("one")
numbers.Enqueue("two")
numbers.Enqueue("three")
numbers.Enqueue("four")
numbers.Enqueue("five")
Dim queueCopy As New Queue(Of String)(numbers.ToArray())
For Each number As String In queueCopy
Console.WriteLine(number)
Next
Dim array2((numbers.Count * 2) - 1) As String
numbers.CopyTo(array2, numbers.Count)
End Sub
End Module
Related examples in the same category