IEnumerable VS IList
In LINQ to query data from collections, we use IEnumerable and IList for data manipulation. IEnumerable is inherited by IList, hence it has all the features of it and except this, it has its own features. IList has below advantage over IEnumerable. In previous article, I explain the difference between IEnumerable and IQueryable.
IList exists in System.Collections Namespace.
IList is used to access an element in a specific position/index in a list.
Like IEnumerable, IList is also best to query data from in-memory collections like List, Array etc.
IList is useful when you want to Add or remove items from the list.
IList can find out the no of elements in the collection without iterating the collection.
IList supports deferred execution.
IList doesn't support further filtering.
IEnumerable exists in System.Collections Namespace.
IEnumerable can move forward only over a collection, it can’t move backward and between the items.
IEnumerable is best to query data from in-memory collections like List, Array etc.
IEnumerable doesn't support add or remove items from the list.
Using IEnumerable we can find out the no of elements in the collection after iterating the collection.
IEnumerable supports deferred execution.
IEnumerable supports further filtering.
In this article I try to explain the difference between IEnumerable and ILIst. I hope after reading this article you will be able to boost your LINQ query performance. I would like to have feedback from my blog readers. Please post your feedback, question, or comments about this article.