ICollection 介面

定義

定義所有非泛型集合的大小、列舉值和同步處理方法。

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> 介面。

介面 ICollectionIEnumerable擴充 ; IDictionary 而且 IList 是擴充 ICollection的特製化介面。 實 IDictionary 作是索引鍵/值組的集合,例如 Hashtable 類別。 實 IList 作是值的集合,而且其成員可以透過索引存取,例如 ArrayList 類別。

某些集合會限制其元素的存取,例如 Queue 類別和 Stack 類別,直接實作 ICollection 介面。

如果介面或IList介面都不符合IDictionary必要集合的需求,請改為從 介面衍生新的集合類別,ICollection以獲得更大的彈性。

如需此介面的泛型版本,請參閱 System.Collections.Generic.ICollection<T>

屬性

Count

取得 ICollection 中所包含的項目數。

IsSynchronized

取得值,這個值表示對 ICollection 的存取是否同步 (安全執行緒)。

SyncRoot

取得可用以同步存取 ICollection 的物件。

方法

CopyTo(Array, Int32)

從特定的 ICollection 索引開始,將 Array 的項目複製到 Array

GetEnumerator()

傳回逐一查看集合的列舉值。

(繼承來源 IEnumerable)

擴充方法

Cast<TResult>(IEnumerable)

IEnumerable 的項目轉換成指定的型別。

OfType<TResult>(IEnumerable)

根據指定的型別來篩選 IEnumerable 的項目。

AsParallel(IEnumerable)

啟用查詢的平行化作業。

AsQueryable(IEnumerable)

IEnumerable 轉換成 IQueryable

適用於

另請參閱