IEnumerable vs. IList

"How to Use" IEnumerable and IList [IEnumerable vs. IList]

When you should use IEnumerable and when IList?

You should use IList when you need access by index to your collections and also when you need Add, delete, modify, ordering and / or positioning of your elements in the collections etc.

You should use IEnumerable when you need to enumerate over your collection and represents a forward only cursor and also for querying data from in memory collections like Array, List, and collations etc.

Stayed Informed - IEnumerable vs. IQueryable

Actually, IList interface implements both the interfaces ICollection and IEnumerable and this interface allows us to add, remove, modify and ordering or positioning to items in the collections.

The IList interface has more power than the preceding two interfaces ICollection and IEnumerable.
The IList Interface contains as,
1.      Indexer
2.      Indexof Method
3.      Add Method
4.      Remove Method
5.      RemoveAt Method
6.      Clear Method
7.      Contains Method
8.      Insert Method
9.      IsFixedSize Property
10.  IsReadOnly Property

Stayed Informed - IEnumerable vs. IQueryable

I hope you are enjoying with this post! Please share with you friends. Thank you!!!

Anil Singh is an author, tech blogger, and software programmer. Book writing, tech blogging is something do extra and Anil love doing it. For more detail, kindly refer to this link..

My Tech Blog -
My Books - Book 1 and Book 2 Powered by Blogger.