System.Collections Namespace
Types
- ICollection
- IDictionary
- IEnumerable
- IEnumerator
- IList
- IObjectCollection
- IObjectDictionary
- IObjectList
Classes
- ArrayList
- CaseInsensitiveComparer
- CaseInsensitiveHashCodeProvider
- CollectionBase
- DictionaryBase
- Hashtable
- Queue
- ReadOnlyCollectionBase
- SortedList
- Stack
Interfaces
The System.Collections namespace defines several fundamental interfaces for collections:
IEnumerable: Supports iteration over a generic collection. Provides a single method,GetEnumerator, which returns an enumerator for the collection.ICollection: Represents a group of objects of the same type. Inherits fromIEnumerable.IDictionary: Represents a collection of key/value pairs. Inherits fromICollection.IList: Represents a non-generic collection of objects that can be individually accessed by index. Inherits fromICollection.IEnumerator: Supports a simple iteration over a collection.
Classes
This namespace also provides several concrete classes that implement these interfaces, offering common collection functionalities:
ArrayList
Implements a dynamic array of objects. It can grow or shrink as needed.
public class ArrayList : IList, ICollection, IEnumerable
Hashtable
Implements a collection of key-value pairs that are organized based on the hash code of the keys. Offers efficient lookups.
public class Hashtable : IDictionary, ICollection, IEnumerable
Queue
Represents a first-in, first-out (FIFO) collection of objects.
public class Queue : ICollection, IEnumerable
Stack
Represents a last-in, first-out (LIFO) collection of objects.
public class Stack : ICollection, IEnumerable
SortedList
Implements a collection that maintains a sorted list of elements, where each element is a key/value pair. Keys are sorted and can be accessed by index.
public class SortedList : IDictionary, ICollection, IEnumerable
CollectionBase
Provides a base class for creating custom collection classes. It simplifies implementing the IList and ICollection interfaces.
public abstract class CollectionBase : IList, ICollection, IEnumerable
DictionaryBase
Provides a base class for creating custom dictionary collection classes. It simplifies implementing the IDictionary and ICollection interfaces.
public abstract class DictionaryBase : IDictionary, ICollection, IEnumerable
ReadOnlyCollectionBase
Provides a base class for custom read-only collection classes. Objects in a read-only collection cannot be modified.
public abstract class ReadOnlyCollectionBase : ICollection, IEnumerable
CaseInsensitiveComparer
Compares two objects for inequality using case-insensitive string comparison.
public class CaseInsensitiveComparer : IComparer
CaseInsensitiveHashCodeProvider
Provides a hash code implementation that is insensitive to case for string keys.
public class CaseInsensitiveHashCodeProvider : IHashCodeProvider