Mega Code Archive

 
Categories / C# Book / 03 Collections
 

0344 ICollection and IList Interfaces

The functionalities of ICollection, IList and IEnuerable are listed in the following table. Interfaces Functionalities IEnumerable<T> (and IEnumerable) Enumerable ICollection<T> (and ICollection) Countable IList <T>/IDictionary <K,V> and their nongeneric versions Accessible by index/key interface ICollection<T> is defined as follows: public interface ICollection<T> : IEnumerable<T>, IEnumerable { int Count { get; } bool Contains (T item); void CopyTo (T[] array, int arrayIndex); bool IsReadOnly { get; } void Add(T item); bool Remove (T item); void Clear(); } The nongeneric ICollection is similar in providing a countable collection: public interface ICollection : IEnumerable { int Count { get; } bool IsSynchronized { get; } object SyncRoot { get; } void CopyTo (Array array, int index); }