O'Reilly logo

C# 3.0 Cookbook, 3rd Edition by Stephen Teilhet, Jay Hilyard

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

Chapter 5. Collections

5.0. Introduction

Collections are groups of items; in .NET, collections contain objects, and each object contained in a collection is called an element. Some collections contain a straight-forward list of elements, while others (dictionaries) contain a list of key and value pairs. The following collection types consist of a straightforward list of elements:

	System.Collections.ArrayList
	System.Collections.BitArray
	System.Collections.Queue
	System.Collections.Stack
	System.Collections.Generic.LinkedList<T>
	System.Collections.Generic.List<T>
	System.Collections.Generic.Queue<T>
	System.Collections.Generic.Stack<T>
	System.Collections.Generic.HashSet<T>

The following collection types are dictionaries:

	System.Collections.Hashtable
	System.Collections.SortedList
	System.Collections.Generic.Dictionary<T,U>
	System.Collections.Generic.SortedList<T,U>

The following collection type is a new addition to the .NET Framework Class Library (FCL), which can be thought of as a list of elements with no duplicates:

	System.Collections.Generic.HashSet<T>

These collection classes are organized under the System.Collections and the System. Collections.Generic namespaces. In addition to these namespaces, another name-space called System.Collections.Specialized contains a few more useful collection classes. These classes might not be as well known as the previous classes, so here is a short explanation of the collection classes under the System.Collections.Specialized namespace:

ListDictionary ...

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