Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
返回 IOrderedEnumerable 而不是 IEnumerable 的方法是否有利?
仅当您希望人们每次都订购该可枚举并且发现很难弄清楚如何做到这一点时,或者您可以提供一个实现该接口的集合,该接口可以有效地对其内容进行排序并与一个知道的扩展方法配对你的收藏。
最好的选择是返回特定的集合类型(有关详细信息,请参阅 Richter)。100 人中有 99 人甚至可以使用标准的 linq 扩展方法来订购它,只要他们愿意。
具体来说,如果它对进一步的调用有意义,那么它是值得做的.ThenBy,而不是其他的。
.ThenBy