Please enable Javascript to correctly display the contents on Dot Net Tricks!

IEnumerable VS IList

 Print 
  Author : Shailendra Chauhan
Posted On : 16 Jun 2012
Total Views : 79,420   
Updated On : 24 Sep 2016
 

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

  1. IList exists in System.Collections Namespace.

  2. IList is used to access an element in a specific position/index in a list.

  3. Like IEnumerable, IList is also best to query data from in-memory collections like List, Array etc.

  4. IList is useful when you want to Add or remove items from the list.

  5. IList can find out the no of elements in the collection without iterating the collection.

  6. IList supports deferred execution.

  7. IList doesn't support further filtering.

IEnumerable

  1. IEnumerable exists in System.Collections Namespace.

  2. IEnumerable can move forward only over a collection, it can’t move backward and between the items.

  3. IEnumerable is best to query data from in-memory collections like List, Array etc.

  4. IEnumerable doesn't support add or remove items from the list.

  5. Using IEnumerable we can find out the no of elements in the collection after iterating the collection.

  6. IEnumerable supports deferred execution.

  7. IEnumerable supports further filtering.

Summary

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.



Free Interview Books
 
COMMENTS
24 SEP
Angular2 and Angular4 (Classroom)
08:30 AM-11:30 AM IST
23 SEP
MEAN Stack (Classroom)
8:30 Am To 11:30 Am
23 SEP
Microsoft Azure Infrastructure Solutions (Online)
08:00 PM-11:00 PM IST / 9:30 AM-12:30 PM CST
20 SEP
MEAN Stack (Online)
07:00 AM-09:00 AM IST
20 SEP
ASP.NET MVC with Angular4 (Online)
9:00PM- 11:00PM IST(+5:30GMT)
16 SEP
Angular2 and Angular4 (Online)
08:00 AM-10:00 AM IST(+5.30 GMT)
7 SEP
ASP.NET MVC with Angular4 (Online)
09:00 PM to 11:00 PM IST (+5:30 GMT)
22 AUG
ASP.NET Core with Angular4 (Online)
07:00 AM - 9:00 AM IST(+5:30 GMT)
19 AUG
MEAN Stack 2 (Online)
5:30 Pm - 7:00 PM IST (+5:30 GMT)
19 AUG
ASP.NET MVC with Angular4 (Online)
10:30 Am to 12:30 PM IST (+ 5:30 GMT)
19 AUG
NodeJS with Angular4 (Classroom)
04:00 PM to 07:00 PM IST (+5:30 GMT)
12 AUG
ASP.NET MVC with Angular4 (Classroom)
11:30 AM - 1:30 PM IST (+5:30GMT)
15 JUL
ASP.NET MVC with Angular4 (Online)
03:30 PM - 05:30 PM IST(+5.30 GMT)
LIKE US ON FACEBOOK
 
+