Chapter 7: Collections
In the previous chapter, we learned about generic programming in C#. One of the most important applications of generics is creating generic collections. A collection is a group of objects. We learned how to use arrays in Chapter 2, Data Types and Operators. However, arrays are sequences of a fixed size and in most cases, we need to work with sequences of variable size.
The .NET frameworks provide generic classes that represent various types of collections, such as list, queue, set, map, and others. Using these classes, we can easily perform operations such as insert, update, delete, sort, and search on a collection of objects.
You will learn about the following generic collections in this chapter:
- The
List<T>
collection - The
Stack<T>
collection - The
Queue<T>
collection - The
LinkedList<T>
collection - The
Dictionary<TKey, TValue>
collection - The
HashSet<T>
collection
By the end of this chapter...