Collections
Last updated
Last updated
System.Collections
classesThe classes in the System.Collections
namespace do not store elements as specifically typed objects, but as objects of type Object
.
Class | Description |
---|---|
ArrayList | Represents an array of objects whose size is dynamically increased as required. |
Hashtable | Represents a collection of key/value pairs that are organized based on the hash code of the key. |
Queue | Represents a first in, first out (FIFO) collection of objects. |
Stack | Represents a last in, first out (LIFO) collection of objects. |
The System.Collections.Specialized namespace provides specialized and strongly typed collection classes, such as string-only collections and linked-list and hybrid dictionaries.
System.Collections.Generic
classesA generic collection enforces strong typing by allowing only the desired data type to be added. A generic collection is useful when every item in the collection has the same data type.
Class | Description |
---|---|
| Represents a collection of key/value pairs that are organized based on the key. |
| Represents a list of objects that can be accessed by index. Provides methods to search, sort, and modify lists. |
| Represents a first in, first out (FIFO) collection of objects. |
| Represents a last in, first out (LIFO) collection of objects. |
Dictionary<TKey, TValue>()
Dictionary internally stores object in an array, but unlike a list, where objects are added at the end of the array (or at the index), the index is calculated using a hash function.
List<T>
List internally uses arrays, if it becomes full it'll create a new larger array and copy content from the older array to the new one.
System.Collections.Concurrent
classesA concurrent collection provide efficient thread-safe operations for accessing collection items from multiple threads.