Code inspection: Redundant 'orderby' clause 'ascending' keyword
This inspection reports the ascending keyword in a query orderby clause because ascending order is already the default. Removing the keyword makes the query shorter without changing its behavior.
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;
}
}
13 April 2026