Why does List not implement IOrderedEnumerable?

后端 未结 2 776
囚心锁ツ
囚心锁ツ 2021-02-19 19:54

I would like to work with ordered enumerables, and use interfaces as return types rather than the concrete types. I need to return an ordered set of objects. Bu

2条回答
  •  梦如初夏
    2021-02-19 20:26

    Well, you are wrong: List is NOT ordered by a particular key. The elements inside the list are in the order you put them in. That's the reason, why List doesn't implement IOrderedEnumerable.
    Just return the following:

    ViewModel.SeriesRepository.OfType().OrderBy();
    

提交回复
热议问题