Why linq extension methods return concrete type

Viewed 79

I know the benefit of declaring interface type instead of concrete type in method signatures. We can find a lot of explanation around here and I won't list them, that's not the point of my question.

My question is about linq. Why, when we saw that declaring interface types in methods signatures for API is a better practice, some linq extension methods are returning concrete type?

For example:

  • ToList() return a List<> and not an IList<>.
  • ToDictionary() returns a Dictionary<> and not an IDictionary<>
  • etc

I was wondering it because I planed to extends the Enumerable extensions methods with my owns and my good practices were telling me to declare interface types when I remembered linq was declaring concrete implementations.

So what should I do? Declare concrete type or interface type?

1 Answers
Related