My question is related to this one concerning the use of IEnumerable
vs IReadOnlyCollection
.
I too have always used
Having thought about this further, I have come to the conclusion, based on the article I mentioned in my Question, that it is indeed OK to use IReadOnlyCollection<T>
as a parameter, but only in functions where it will definitely be enumerated. If enumeration is conditional based on other parameters, object state, or workflow, then it should still be passed in as IEnumerable<T>
so that lazy evaluation is semantically ensured.