Поделиться через


ICollection Interface

Microsoft Silverlight will reach end of support after October 2021. Learn more.

Defines size, enumerators, and synchronization methods for all nongeneric collections.

Namespace:  System.Collections
Assembly:  mscorlib (in mscorlib.dll)

Syntax

'Declaration
<ComVisibleAttribute(True)> _
Public Interface ICollection _
    Inherits IEnumerable
[ComVisibleAttribute(true)]
public interface ICollection : IEnumerable

The ICollection type exposes the following members.

Properties

  Name Description
Public propertySupported by Silverlight for Windows PhoneSupported by Xbox 360 Count Gets the number of elements contained in the ICollection.
Public propertySupported by Silverlight for Windows PhoneSupported by Xbox 360 IsSynchronized Gets a value indicating whether access to the ICollection is synchronized (thread safe).
Public propertySupported by Silverlight for Windows PhoneSupported by Xbox 360 SyncRoot Gets an object that can be used to synchronize access to the ICollection.

Top

Methods

  Name Description
Public methodSupported by Silverlight for Windows PhoneSupported by Xbox 360 CopyTo Copies the elements of the ICollection to an Array, starting at a particular Array index.
Public methodSupported by Silverlight for Windows PhoneSupported by Xbox 360 GetEnumerator Returns an enumerator that iterates through a collection. (Inherited from IEnumerable.)

Top

Extension Methods

  Name Description
Public Extension MethodSupported by Silverlight for Windows Phone AsQueryable Converts an IEnumerable to an IQueryable. (Defined by Queryable.)
Public Extension MethodSupported by Silverlight for Windows PhoneSupported by Xbox 360 Cast<TResult> Converts the elements of an IEnumerable to the specified type. (Defined by Enumerable.)
Public Extension MethodSupported by Silverlight for Windows PhoneSupported by Xbox 360 OfType<TResult> Filters the elements of an IEnumerable based on a specified type. (Defined by Enumerable.)

Top

Remarks

The ICollection interface is the base interface for classes in the System.Collections namespace.

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. An IList implementation is a collection of values and its members can be accessed by index.

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>.

Version Information

Silverlight

Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

XNA Framework

Supported in: Xbox 360, Windows Phone OS 7.0

Platforms

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.