C# 中的 ICollection 接口有何作用
csharpprogrammingserver side programming更新于 2025/10/14 22:37:17
C# 中的 ICollection 接口定义了所有非泛型集合的大小、枚举器和同步方法。它是 System.Collections 命名空间中类的基接口。
以下是 ICollection 接口的属性 −
| Sr.No. | 属性名称 &说明 |
|---|---|
| 1 | Count ICollection 中的元素数量 |
| 2 | SyncRoot 获取用于同步对 ICollection 访问的对象。 |
以下是 ICollection 接口的方法 −
| Sr.No. | 方法名称 &说明 |
|---|---|
| 1 | CopyTo(Array^,Int32) 该方法将 ICollection 的元素复制到数组。 |
| 2 | GetEnumerator() GetEnumerator() 方法返回一个遍历集合的枚举器 |

