Name

Queue.Dequeue Method

Class

System.Collections.Queue

Syntax

                  queuevariable.Dequeue(  )

Return Value

Object

Description

Removes the first item from the queue and returns it as an Object

Rules at a Glance

  • Dequeue removes the item at the beginning of the queue and decrements the Count property by one.

  • The Dequeue method generates an error if applied to an empty queue. Thus, it may be advisable to check for an empty queue using the Count property before attempting to dequeue.

Programming Tips and Gotchas

Dequeue is similar to the Peek method. The Peek method returns a reference to the object at the beginning of the queue, but unlike the Dequeue method, does not remove it from the queue.

Get VB.NET Language in a Nutshell, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.