When I\'m writing my DAL or other code that returns a set of items, should I always make my return statement:
public IEnumerable GetRecentItems
I think you can use either, but each has a use. Basically List
is IEnumerable
but you have count functionality, Add element, remove element
IEnumerable
is not efficient for counting elements, or getting a specific element in the collection.
List
is a collection which is ideally suited to finding specific elements, easy to add elements, or remove them.
Generally I try to use List
where possible as this gives me more flexibility.
Use
List
rather than
IList