Returning ‘IList’ vs ‘ICollection’ vs ‘Collection’

ICollection<T> is an interface that exposes collection semantics such as Add(), Remove(), and Count.

Collection<T> is a concrete implementation of the ICollection<T> interface.

IList<T> is essentially an ICollection<T> with random order-based access.

In this case you should decide whether or not your results require list semantics such as order based indexing (then use IList<T>) or whether you just need to return an unordered “bag” of results (then use ICollection<T>).

Leave a Comment