Rediger

Del via


ascending (C# Reference)

Use the ascending contextual keyword in the orderby clause of query expressions to specify that the sort order goes from smallest to largest. Because ascending is the default sort order, you don't need to specify it.

The C# language reference documents the most recently released version of the C# language. It also contains initial documentation for features in public previews for the upcoming language release.

The documentation identifies any feature first introduced in the last three versions of the language or in current public previews.

Tip

To find when a feature was first introduced in C#, consult the article on the C# language version history.

The following example shows how to use ascending in an orderby clause.

IEnumerable<string> sortAscendingQuery =
    from vegetable in vegetables
    orderby vegetable ascending
    select vegetable;

See also