ICollection ICollection ICollection ICollection Interface


定義所有非泛型集合的大小、列舉值和同步處理方法。Defines size, enumerators, and synchronization methods for all nongeneric collections.

public interface class ICollection : System::Collections::IEnumerable
public interface ICollection : System.Collections.IEnumerable
type ICollection = interface
    interface IEnumerable
Public Interface ICollection
Implements IEnumerable


介面是System.Collections命名空間中類別的基底介面。 ICollectionThe ICollection interface is the base interface for classes in the System.Collections namespace. 它的泛型對System.Collections.Generic.ICollection<T>等是介面。Its generic equivalent is the System.Collections.Generic.ICollection<T> interface.

介面會擴充IEnumerable; ICollection和是更專門擴充ICollection的介面。 IList IDictionaryThe ICollection interface extends IEnumerable; IDictionary and IList are more specialized interfaces that extend ICollection. 「執行」是索引鍵/值組的集合, Hashtable例如類別。 IDictionaryAn IDictionary implementation is a collection of key/value pairs, like the Hashtable class. 實作為值的集合, 而且它的成員可以透過索引來存取, ArrayList例如類別。 IListAn IList implementation is a collection of values and its members can be accessed by index, like the ArrayList class.

某些集合會限制其元素的存取權, 例如Queue類別StackICollection類別, 會直接執行介面。Some collections that limit access to their elements, such as the Queue class and the Stack class, directly implement the ICollection interface.

如果IDictionary介面ICollection或介面都不符合所需集合的需求, 請改為從介面衍生新的集合類別, 以提供更多彈性。 IListIf neither the IDictionary interface nor the IList interface meet the requirements of the required collection, derive the new collection class from the ICollection interface instead for more flexibility.

如需此介面的泛型版本, 請System.Collections.Generic.ICollection<T>參閱。For the generic version of this interface, see System.Collections.Generic.ICollection<T>.


Count Count Count Count

取得 ICollection 中所包含的項目數。Gets the number of elements contained in the ICollection.

IsSynchronized IsSynchronized IsSynchronized IsSynchronized

取得值,這個值表示對 ICollection 的存取是否同步 (安全執行緒)。Gets a value indicating whether access to the ICollection is synchronized (thread safe).

SyncRoot SyncRoot SyncRoot SyncRoot

取得可用以同步存取 ICollection 的物件。Gets an object that can be used to synchronize access to the ICollection.


CopyTo(Array, Int32) CopyTo(Array, Int32) CopyTo(Array, Int32) CopyTo(Array, Int32)

從特定的 ICollection 索引開始,將 Array 的項目複製到 ArrayCopies the elements of the ICollection to an Array, starting at a particular Array index.

GetEnumerator() GetEnumerator() GetEnumerator() GetEnumerator()

傳回逐一查看集合的列舉值。Returns an enumerator that iterates through a collection.

(Inherited from IEnumerable)


Cast<TResult>(IEnumerable) Cast<TResult>(IEnumerable) Cast<TResult>(IEnumerable) Cast<TResult>(IEnumerable)

IEnumerable 的項目轉換成指定的型別。Casts the elements of an IEnumerable to the specified type.

OfType<TResult>(IEnumerable) OfType<TResult>(IEnumerable) OfType<TResult>(IEnumerable) OfType<TResult>(IEnumerable)

根據指定的型別來篩選 IEnumerable 的項目。Filters the elements of an IEnumerable based on a specified type.

AsParallel(IEnumerable) AsParallel(IEnumerable) AsParallel(IEnumerable) AsParallel(IEnumerable)

啟用查詢的平行化作業。Enables parallelization of a query.

AsQueryable(IEnumerable) AsQueryable(IEnumerable) AsQueryable(IEnumerable) AsQueryable(IEnumerable)

IEnumerable 轉換成 IQueryableConverts an IEnumerable to an IQueryable.