ICollection ICollection ICollection ICollection Interface

定義

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

public interface class ICollection : System::Collections::IEnumerable
[System.Runtime.InteropServices.ComVisible(true)]
public interface ICollection : System.Collections.IEnumerable
type ICollection = interface
    interface IEnumerable
Public Interface ICollection
Implements IEnumerable
衍生
屬性
實作

備註

ICollection介面是基底介面中的類別System.Collections命名空間。The 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.

ICollection介面會擴充IEnumerable;IDictionaryIList是更具特製化的介面,擴充ICollectionThe ICollection interface extends IEnumerable; IDictionary and IList are more specialized interfaces that extend ICollection. IDictionary實作中是索引鍵/值組的集合如Hashtable類別。An IDictionary implementation is a collection of key/value pairs, like the Hashtable class. IList實作是值的集合和其成員可以依照索引存取,例如ArrayList類別。An IList implementation is a collection of values and its members can be accessed by index, like the ArrayList class.

限制存取其項目,例如某些集合Queue類別和Stack類別,請直接實作ICollection介面。Some collections that limit access to their elements, such as the Queue class and the Stack class, directly implement the ICollection interface.

如果既未IDictionary介面也IList介面的所需的集合需求,而衍生新的集合類別,從ICollection介面改為更大的彈性。If 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.

適用於

另請參閱