ICollection Interface
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Defines size, enumerators, and synchronization methods for all nongeneric collections.
public interface class ICollection : System::Collections::IEnumerable
public interface ICollection : System.Collections.IEnumerable
[System.Runtime.InteropServices.ComVisible(true)]
public interface ICollection : System.Collections.IEnumerable
type ICollection = interface
interface IEnumerable
[<System.Runtime.InteropServices.ComVisible(true)>]
type ICollection = interface
interface IEnumerable
Public Interface ICollection
Implements IEnumerable
- Derived
- Attributes
- Implements
The ICollection interface is the base interface for classes in the System.Collections namespace. Its generic equivalent is the System.Collections.Generic.ICollection<T> interface.
The ICollection interface extends IEnumerable; IDictionary and IList are more specialized interfaces that extend ICollection. An IDictionary implementation is a collection of key/value pairs, like the Hashtable class. An IList implementation is a collection of values and its members can be accessed by index, like the ArrayList class.
Some collections that limit access to their elements, such as the Queue class and the Stack class, directly implement the ICollection interface.
If neither the IDictionary interface nor the IList interface meet the requirements of the required collection, derive the new collection class from the ICollection interface instead for more flexibility.
For the generic version of this interface, see System.Collections.Generic.ICollection<T>.
Count |
Gets the number of elements contained in the ICollection. |
Is |
Gets a value indicating whether access to the ICollection is synchronized (thread safe). |
Sync |
Gets an object that can be used to synchronize access to the ICollection. |
Copy |
Copies the elements of the ICollection to an Array, starting at a particular Array index. |
Get |
Returns an enumerator that iterates through a collection. (Inherited from IEnumerable) |
Cast<TResult>(IEnumerable) |
Casts the elements of an IEnumerable to the specified type. |
Of |
Filters the elements of an IEnumerable based on a specified type. |
As |
Enables parallelization of a query. |
As |
Converts an IEnumerable to an IQueryable. |
Product | Versions |
---|---|
.NET | Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9 |
.NET Framework | 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
.NET Standard | 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 2.0, 2.1 |
UWP | 10.0 |
.NET feedback
.NET is an open source project. Select a link to provide feedback: