Storing multiple objects in collections
Another of the most common types of data is collections. If you need to store multiple values in a variable, then you can use a collection.A collection is a data structure in memory that can manage multiple items in different ways, although all collections have some shared functionality.The most common types in .NET for working with collections are shown in Table 8.8:
Namespace | Example type(s) | Description |
System .Collections |
IEnumerable ,IEnumerable<T> |
Interfaces and base classes used by collections. |
System .Collections .Generic |
List<T> ,Dictionary<T> ,Queue<T> ,Stack<T> |
Introduced in C# 2.0 with .NET Framework 2.0. These collections allow you to specify the type you want to store using a generic type parameter (which is safer, faster, and more efficient). |
System .Collections .Concurrent |
BlockingCollection ,ConcurrentDictionary ,ConcurrentQueue |
These collections are safe to use in multithreaded scenarios... |