IReadOnlyList<T>
A .NET interface for an ordered collection that can be read by index and counted, but not changed.
In more detail
List<T> and arrays both implement it. Returning it from a service tells callers the truth: they get results to read, and cannot quietly add to a collection the service owns.
Related terms
- List<T> — The .NET growable array: items keep their order, reading by index is constant time, and searching by value walks the whole list.
- IEnumerable<T> — The .NET interface for any sequence you can loop over one item at a time, the basis of foreach and in-memory LINQ.
Taught in
- Classes, Interfaces, and Object-Oriented C# — Modern .NET Core, C# & Enterprise Microservices
- Collections, Generics, and LINQ — Modern .NET Core, C# & Enterprise Microservices
- The Repository Pattern — Modern .NET Core, C# & Enterprise Microservices