英文:
What are the new "Order" and "OrderDescending" in .NET 7?
问题
今天我意识到,几个月没有使用LINQ后,Intellisense给我提供了OrderDescending
,而不是OrderByDescending
(因为我的肌肉记忆)。关于它的作用以及为什么我应该使用它而不是OrderByDescending
,文档并不是很清楚。文档还说它是新的,并且只在.NET 7中添加。
这个新方法是用来做什么的,何时使用它?
英文:
After a few months not working with LINQ, today I realized Intellisense gave me OrderDescending
instead of OrderByDescending
(due to my muscle memory). The documentation is not very clear on what it does or why I should use it instead of OrderByDescending
. The docs also say it's new and is only added in .NET 7.
What is this new method for and when do you use it?
答案1
得分: 4
这是在.NET 7中添加的执行“identity”排序的新方法,即它等同于:
.OrderByDescending(x => x)
请查看提案 - API提案:Enumerable.Order和OrderDescending以及当前的Enumerable.OrderDescending
实现。
英文:
This is new method added in .NET 7 to perform "identity" sort i.e. it is equivalent of:
.OrderByDescending(x => x)
See the proposal - [API Proposal]: Enumerable.Order and OrderDescending and current Enumerable.OrderDescending
implementation.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论