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.
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,
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
I hope you are enjoying with this post! Please share with you friends. Thank you!!!