ICollection 接口

定义所有非泛型集合的大小、枚举数和同步方法。

**命名空间:**System.Collections
**程序集:**mscorlib(在 mscorlib.dll 中)

语法

声明
<ComVisibleAttribute(True)> _
Public Interface ICollection
    Inherits IEnumerable
用法
Dim instance As ICollection
[ComVisibleAttribute(true)] 
public interface ICollection : IEnumerable
[ComVisibleAttribute(true)] 
public interface class ICollection : IEnumerable
/** @attribute ComVisibleAttribute(true) */ 
public interface ICollection extends IEnumerable
ComVisibleAttribute(true) 
public interface ICollection extends IEnumerable

备注

ICollection 接口是 System.Collections 命名空间中类的基接口。

ICollection 接口扩展 IEnumerableIDictionaryIList 则是扩展 ICollection 的更为专用的接口。IDictionary 实现是键/值对的集合,如 Hashtable 类。IList 实现是值的集合,其成员可通过索引访问,如 ArrayList 类。

某些集合(如 Queue 类和 Stack 类)限制对其元素的访问,它们直接实现 ICollection 接口。

如果 IDictionary 接口和 IList 接口都不能满足所需集合的要求,则从 ICollection 接口派生新集合类以提高灵活性。

有关此接口的泛型版本,请参见 System.Collections.Generic.ICollection

平台

Windows 98、Windows 2000 SP4、Windows CE、Windows Millennium Edition、Windows Mobile for Pocket PC、Windows Mobile for Smartphone、Windows Server 2003、Windows XP Media Center Edition、Windows XP Professional x64 Edition、Windows XP SP2、Windows XP Starter Edition

.NET Framework 并不是对每个平台的所有版本都提供支持。有关受支持版本的列表,请参见系统要求

版本信息

.NET Framework

受以下版本支持:2.0、1.1、1.0

.NET Compact Framework

受以下版本支持:2.0、1.0

请参见

参考

ICollection 成员
System.Collections 命名空间
IDictionary
IList
System.Collections.Generic.ICollection