Generics Sample

To get samples and instructions for installing them, see the following:

  • Click Samples on the Visual Studio Help menu.

    For more information, see Locating Sample Files.

  • The most recent versions and the complete list of samples are available on the Visual Studio 2008 Samples Web site.

  • You can also locate samples on your computer's hard disk. By default, samples and a Readme file are copied to a folder under \Program Files\Visual Studio 9\Samples\. For Visual Studio Express Editions, all samples are located on the Internet.

To run this sample

  • Press F5.

Demonstrates

This sample illustrates the following concepts:

  • Use of the Queue<(Of <(T>)>), List<(Of <(T>)>), Stack<(Of <(T>)>), Dictionary<(Of <(TKey, TValue>)>), and SortedList<(Of <(TKey, TValue>)>) collections from the System.Collections.Generic namespace.

  • A method for sorting the contents of the collection for each collection type.

  • Adding and removing items from the data structures.

The sample contains one form. On startup, the form displays two sets of RadioButton controls, four Button controls, and two ListBox controls. The source ListBox control contains the data being stored. The two RadioButton groups control the type of data and type of collection. The buttons perform the clear, load, sort, and reverse tasks. The resulting collection is shown in the target ListBox control. The code for each collection type is organized in a #Region Directive.