Home » LINQ OrderBy Operator (Ascending)

LINQ OrderBy Operator (Ascending)

by Online Tutorials Library

LINQ OrderBy Operator(Ascending)

In LINQ, the OrderBy operator is used to sort the list/ collection values in ascending order. In LINQ, if we use order by the operator by default, it will sort the list of values in ascending order. We don’t need to add any ascending condition in the query statement.

Syntax of LINQ OrderBy operator

The syntax of LINQ OrderBy operator in LINQ to sort the list/ collection values in ascending order.

C# Code

LINQ OrderBy Operator Example

In the above example, we declared a variable student name of type var and used order by clause in the student collection and mentioned the column named “Name” to sort the list of values in ascending order, which is based on “Name.”

Output

LINQ OrderBy Operator(Ascending)


You may also like