Our next tutorial chapter is C# collections, which is further divided into 3 parts: Generic Collection, Non-Generic Collections and Concurrent, before we procede to look into each of collection type, let's understand what is a collection.
Collection are specialized classes for data storage and retrieval, these classes provide support for stacks, queues, lists and hash tables.
Types of collections:
System.Collections.Generic namespace contains interfaces and classes that define generic collections, which allow users to create strongly typed collections that provide better type safety and performance than non-generic strongly typed collections.
The System.Collections.Generic namespace has following classes:
The namespace contains interfaces and classes that define various collections of objects, such as lists, queues, bit arrays, hash tables and dictionaries.These classes are legacy. It is suggested now to use System.Collections.Generic classes. The
System.Collections namespace has following classes:
System.Collections.Concurrent namespace provides several thread-safe collection classes that should be used in place of the corresponding types in the and namespaces whenever multiple threads are accessing the collection concurrently. However, access to elements of a collection object through extension methods or through explicit interface implementations are not guaranteed to be thread-safe and may need to be synchronized by the caller.
System.Collections.Concurrent namespace has following classes: