Imagine I have a SearchService layer that has a method to search all cars starting with a certain string;
public static class Searcher{
public IAnInterface&l
My rule of thumb is as follows:
If there is ever a chance that I can take the routine's core algorithm and refactor it in a way that I can use yield returns, I will go with IEnumerable
For example, if my current implementation uses an array or a List
I've found that the gains of returning IEnumerable
However, if the algorithm, in its very nature, is going to need to fully evaluate the results before returning (rare, but does happen), I will go with an IList
I rarely return IQueryable. The only time I would use this interface is if I'm directly creating a queryable data access layer, or something similar. The overhead of using this is, in most cases, not worth the gains.
However, if your goal is to always use a single interface (I don't necessarily agree with this goal), I would stick to IEnumerable