Backend line

Collections

Lists, dictionaries, LINQ, enumerables

5 sections

Start: ICollection

Foundational 3

  1. ICollectionICollection<T> extends IEnumerable<T> with an O(1) Count property plus Add, Remove, Clear, and Contains, so it's the right contract when callers genuinely need a size check or mutation without caring about indexed access. Reach for it…, not read
  2. IEnumerableIEnumerable<T> is the minimal "forward-only, read-only, lazy" sequence contract that every LINQ pipeline and foreach loop is built on. Returning it from APIs hides the concrete collection, enables deferred execution so filters compose…, not read
  3. IListIList<T> extends ICollection<T> with an indexer plus Insert, RemoveAt, and IndexOf, exposing random access at index i. Use it when callers truly need positional reads or insert-at-position semantics (an order book, a price ladder);…, not read

Mid-level 2

  1. IQueryableIQueryable<T> looks like IEnumerable<T> but builds an expression tree instead of executing immediately, letting providers like EF Core translate the whole composed pipeline into a single SQL statement. Returning it from repositories…, not read
  2. IReadOnlyIReadOnlyCollection<T> and IReadOnlyList<T> expose Count (and indexed access in the latter) without surfacing Add, Remove, or Clear, so callers can read and iterate but can't mutate your internal state. List<T> already implements both…, not read