ICollection and IList Interfaces

The functionalities of ICollection, IList and IEnuerable are listed in the following table.

InterfacesFunctionalities
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);
}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.