Chapter 7. Collections
.NET provides a standard set of types for storing and managing collections of objects. These include resizable lists, linked lists, sorted and unsorted dictionaries, and arrays. Of these, only arrays form part of the C# language; the remaining collections are just classes you instantiate like any other.
We can divide the types in the .NET BCL for collections into the following categories:
-
Interfaces that define standard collection protocols
-
Ready-to-use collection classes (lists, dictionaries, etc.)
-
Base classes for writing application-specific collections
This chapter covers each of these categories, with an additional section on the types used in determining element equality and order.
The collection namespaces are as follows:
Namespace | Contains |
---|---|
System.Collections |
Nongeneric collection classes and interfaces |
System.Collections.Specialized |
Strongly typed nongeneric collection classes |
System.Collections.Generic |
Generic collection classes and interfaces |
System.Collections.ObjectModel |
Proxies and bases for custom collections |
System.Collections.Concurrent |
Thread-safe collections (see Chapter 22) |
Enumeration
In computing, there are many different kinds of collections, ranging from simple data structures, such as arrays or linked lists, to more complex ones, such as red/black trees and hashtables. Although the internal implementation and external characteristics of these data structures vary widely, the ability to traverse the contents ...
Get C# 10 in a Nutshell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.