Should I return an IEnumerable or IList? [closed]

There is a hierarchy here:

interface IList<T> : ICollection<T> { } 
interface ICollection<T> : IEnumerable<T> { }

You want to aim for the least possible coupling, so return an IEnumerable<T> if that is enough. It probably will be.

Return an IList<T> if the situation requires that the caller gets a List that it can use to Add/Insert/Remove. But even then it might be better if the caller created his own List from the IEnumerable collection.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)