I know IList would do the job
Actually, it would not. No interface can ever possibly have such a guarantee, because I can always make an implementation of that interface that defers materialization of any query until some of the interface methods are called. Now, by convention, a type implementing IList
would be a materialized collection, and not something deferring work, but that is not a guarantee.
To have a guarantee you'll need to use a concrete type rather than an interface, accepting an array, List
, etc.
Of course one option that you have is to accept an interface such as IEnumerable
and then materialize it into a collection yourself (possibly as a 3rd overload with overloads for arrays and lists to avoid the need to re-materialize those) because if you've materialized it yourself then you know it's not deferring execution.