Collections are a list or a container which can hold entities. Each have different use cases.
Interface Collections That Support Iteration
IEnumerable
This is the most basic type of container. Exposes an enumerator, which supports a simple iteration over a non-generic collection. You cannot add, delete or update and there are no count methods, to get a count you would need to iterate over all entities.
1 | // Methods |
ICollection
Extends IEnumerable
and defines size, enumerators, and synchronization methods for all non-generic collections. Has functionality to add, remove, update entities in the container and get the count.
1 | // Properties |
IList
Extends IEnumerable
and represents a non-generic collection of objects that can be individually accessed by index, it supports the same functionality to add, remove, update entities in the container.
1 | // Properties |
Other Interface Collections
IReadOnlyCollection
Represents a strongly-typed, read-only collection of elements.
IReadOnlyList
Represents a read-only collection of elements that can be accessed by index.