VB.net Program to Copy the Queue Elements Into an Array Using the Collection

You are currently viewing VB.net Program to Copy the Queue Elements Into an Array Using the Collection

VB.Net program to copy the queue elements into an array using the collection

'VB.Net program to copy the queue elements into the array 
'using the collection. 

Imports System
Imports System.Collections

Module Module1
    Sub Main()

        Dim arr(4) As String
        Dim queue As New Queue(5)

        queue.Enqueue("India")
        queue.Enqueue("USA")
        queue.Enqueue("UK")
        queue.Enqueue("CHINA")

        queue.CopyTo(arr, 0)

        Console.WriteLine("Array elements are:")
        For i = 0 To 3 Step 1
            Console.WriteLine(vbTab & "Item[" & (i + 1) & "]: " & arr(i))
        Next
    End Sub
End Module
Array elements are:
        Item[1]: India
        Item[2]: USA
        Item[3]: UK
        Item[4]: CHINA
Press any key to continue . . .

Ranjith Kumar

Hi, I'm Ranjith a full-time Blogger, YouTuber, Affiliate Marketer, & founder of Coding Diksha. Here, I post about programming to help developers.

Leave a Reply