11.2 集合接口和类型

大多数集合类都可在System.Collections和System.Collections.Generic名称空间中找到。泛型集合类位于System.Collections.Generic名称空间中;专用于特定类型的集合类位于System.Collections. Specialized名称空间中。线程安全的集合类位于System.Collections.Concurrent名称空间中。不可变的集合类在System.Collections.Immutable名称空间中。

当然,组合集合类还有其他方式。集合可以根据集合类实现的接口组合为列表、集合和字典。

注意:接口IEnumerable和IEnumerator的内容详见第7章。

集合和列表实现的接口如表11-1所示。

表11-1