代码检查:冗余的 'orderby' 子句中的 'ascending' 关键字
此检查会报告查询 ascending 子句中的 orderby 关键字,因为升序已是默认排序方式。 移除该关键字可以缩短查询语句,而不会改变其行为。
using System.Collections.Generic;
using System.Linq;
class C
{
IEnumerable<int> M(IEnumerable<int> values)
{
return from value in values
orderby value ascending
select value;
}
}
using System.Collections.Generic;
using System.Linq;
class C
{
IEnumerable<int> M(IEnumerable<int> values)
{
return from value in values
orderby value
select value;
}
}
2026年 5月 8日