When To Use IEnumerable, ICollection, IList And List

| Interface | Scenario |
| IEnumerable, IEnumerable<T> | The only thing you want is to iterate over the elements in a collection. You only need read-only access to that collection. |
| ICollection, ICollection<T> | You want to modify the collection or you care about its size. |
| IList, IList<T> | You want to modify the collection and you care about the ordering and / or positioning of the elements in the collection. |
| . | . |
No comments:
Post a Comment