ICollection 介面
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
定義所有非泛型集合的大小、列舉值和同步處理方法。
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
- 衍生
- 屬性
- 實作
ICollection 介面是 System.Collections 命名空間中類別的基底介面。 其泛型對等專案是 System.Collections.Generic.ICollection<T> 介面。
ICollection 介面會擴充 IEnumerable;IDictionary 和 IList 是擴充 ICollection的更特製化介面。 IDictionary 實作是索引鍵/值組的集合,例如 Hashtable 類別。 IList 實作是值的集合,而且其成員可以透過索引存取,例如 ArrayList 類別。
某些集合會限制其元素的存取,例如 Queue 類別和 Stack 類別,直接實作 ICollection 介面。
如果 IDictionary 介面和 IList 介面都不符合必要集合的需求,請改為從 ICollection 介面衍生新的集合類別,以獲得更大的彈性。
如需此介面的泛型版本,請參閱 System.Collections.Generic.ICollection<T>。
Count |
取得包含在 ICollection中的項目數目。 |
Is |
取得值,指出是否同步存取 ICollection (線程安全)。 |
Sync |
取得對象,這個物件可用來同步存取 ICollection。 |
Copy |
從特定 Array 索引開始,將 ICollection 的專案複製到 Array。 |
Get |
傳回逐一查看集合的列舉值。 (繼承來源 IEnumerable) |
Cast<TResult>(IEnumerable) |
將 IEnumerable 的項目轉換成指定的型別。 |
Of |
根據指定的型別篩選 IEnumerable 的專案。 |
As |
啟用查詢的平行處理。 |
As |
將 IEnumerable 轉換成 IQueryable。 |
產品 | 版本 |
---|---|
.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, 10 |
.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 |