在.NET 7中,“Order”和“OrderDescending”是什么?

huangapple go评论110阅读模式
英文:

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.

huangapple
  • 本文由 发表于 2023年7月24日 16:58:37
  • 转载请务必保留本文链接:https://go.coder-hub.com/76752858.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定