O'Reilly logo

Microsoft® Visual Basic® .NET Programmer's Cookbook by Matthew MacDonald

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Use a Queue (FIFO Collection)

Problem

You need a collection where items will be retrieved in the same order they are added.

Solution

Use the System.Collections.Queue type, which provides a first-in, first-out collection.

Discussion

Queues are used for a variety of sequential programming tasks. For example, you might use a queue to store a list of tasks that needs to be performed with a server-side component. Because the queue is a first-in, first-out collection, the oldest items are always dealt with first.

Conceptually, the Queue is a dynamically sized array that stores objects, much as the ArrayList does. The Queue starts with an initial capacity of 32 items (unless you supply a different capacity in the constructor) and doubles the capacity as needed. ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required