ICollection Interface (System)
The ICollection interface defines size, enumerators, and synchronization methods for all nongeneric collections.
Overview
Properties
Methods
Remarks
Inheritance
Object → ICollection
Implements
None
Derived Interfaces
Properties
Name | Type | Description |
---|---|---|
Count | int | Gets the number of elements contained in the ICollection. |
IsSynchronized | bool | Gets a value indicating whether access to the ICollection is synchronized (thread safe). |
SyncRoot | object | Gets an object that can be used to synchronize access to the ICollection. |
Methods
Name | Signature | Description |
---|---|---|
CopyTo | void CopyTo(Array array, int index) | Copies the elements of the ICollection to an Array, starting at a particular Array index. |
GetEnumerator | IEnumerator GetEnumerator() | Returns an enumerator that iterates through the collection. |
Remarks
The ICollection interface forms the basis for classes that represent collections of objects. It provides the ability to determine the size of the collection, to synchronize access, and to copy the collection to an array. Most generic collection interfaces (e.g., ICollection<T>) extend this non‑generic interface.
Thread Safety
Implementations of ICollection that are not inherently thread‑safe should set IsSynchronized to false
and provide a SyncRoot that can be used for external synchronization.