Queue.Enqueue and ToArray : Queue « Collections « VB.Net Tutorial






Imports System.Collections

public class Test
   Private Shared m_Queue As New Queue
   public Shared Sub Main
        
        m_Queue.Enqueue("A")
        DisplayQueue()

        m_Queue.Enqueue("B")
        DisplayQueue()

        m_Queue.Enqueue("C")
        DisplayQueue()

        Dim txt As String = DirectCast(m_Queue.Dequeue(), String)
        Console.WriteLine(txt)
        DisplayQueue()
   End Sub
    Private Shared Sub DisplayQueue()
        For Each str As String In m_Queue.ToArray()
            Console.WriteLine(str)
        Next str
    End Sub
End class
A
A
B
A
B
C
A
B
C








8.26.Queue
8.26.1.Queue
8.26.2.Enqueue, Dequeue and Peek
8.26.3.Queue.Enqueue and ToArray
8.26.4.Create a copy of the queue, using the ToArray method and the constructor that accepts an IEnumerable(Of T).
8.26.5.A queue can be enumerated without disturbing its contents.
8.26.6.Dequeuing,Peek and Dequeuing again
8.26.7.Copy the elements of the queue, starting at the middle of the array.
8.26.8.Queue.Contains
8.26.9.The Contains method is used to show that the string "four" is in the first copy of the queue