What’s In This Chapter?
- Understanding collection interfaces and types
- Working with lists, queues, and stacks
- Working with linked and sorted lists
- Using dictionaries and sets
- Evaluating performance
Wrox.com Code Downloads for This Chapter
The wrox.com code downloads for this chapter are found at http://www.wrox.com/go/professionalcsharp6 on the Download Code tab. The code for this chapter is divided into the following major examples:
- List Samples
- Queue Sample
- Linked List Sample
- Sorted List Sample
- Dictionary Sample
- Set Sample
Chapter 7, “Arrays and Tuples,” covers arrays and the interfaces implemented by the Array class. The size of arrays is fixed. If the number of elements is dynamic, you should use a collection class instead of an array.
List<T> is a collection class that can be compared to arrays; but there are also other kinds of collections: queues, stacks, linked lists, dictionaries, and sets. The other collection classes have partly different APIs to access the elements in the collection and often a different internal structure for how the items are stored in memory. This chapter covers all of these collection classes and their differences, including performance differences.
This chapter also discusses bit arrays and concurrent collections that can be used from multiple threads.
Collection Interfaces and Types
Most collection classes are in the System.Collections and System.Collections.Generic namespaces. Generic collection classes are ...