C# C# LINQ Examples

LINQ – OrderBy & OrderByDescending With C# Programming Example

In this tutorial we’ll learn Linq OrderBy and OrderByDescending Operators.

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

OrderBy and OrderByDescending, both are a sorting operator that sorts the elements in a collection. OrderBy sorts elements in ascending order, whereas OrderByDescending Operator sorts element in descending order.

LINQ – OrderBy Example:

Output:

LINQ – OrderByDescending Example:

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.