Linq OrderByDescending Operator - How to order a sequence by values in descending order
LinqOrderByDescendingOperator.aspx
<%@ Page Language="C#" AutoEventWireup="true" %>
<%@ Import Namespace="System.Linq" %>
<!DOCTYPE html>
<script runat="server">
protected void Button1_Click(object sender, System.EventArgs e)
{
string[] fruits = { "Birne", "Achras zapota", "Wood apple", "Tamarindenbaum", "Kasjoema", "Coffee" };
IEnumerable<string> val = from f in fruits
where f.Count()>5
orderby f descending
select f;
Label1.Text = "Fruits List: <br />";
foreach (string names in fruits)
{
Label1.Text += names.ToString() + "<br />";
}
Label2.Text = "Filtered And Descending Ordered Fruits: Count()>5 <br />";
foreach (string n in val)
{
Label2.Text += n + "<br />";
}
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>Linq OrderByDescending Operator - How to order a sequence by values in descending order</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<h2 style="color:DarkBlue; font-style:italic;">
Linq Standard Query Operator - OrderByDescending
<br />How to order a sequence by values in descending order
</h2>
<hr width="500" align="left" color="CornFlowerBlue" />
<asp:Label
ID="Label1"
runat="server"
Font-Size="X-Large"
ForeColor="Magenta"
Font-Italic="true"
>
</asp:Label>
<br />
<asp:Label
ID="Label2"
runat="server"
Font-Size="X-Large"
ForeColor="MediumBlue"
Font-Italic="true"
>
</asp:Label>
<br />
<asp:Button
ID="Button1"
runat="server"
OnClick="Button1_Click"
Text="Test Linq Query Operator - OrderByDescending"
Height="45"
Font-Bold="true"
ForeColor="DodgerBlue"
/>
</div>
</form>
</body>
</html>

- linq - How to count items of a sequence
- linq - How to get maximum value of a numeric sequence
- linq - How to get minimum value from a numeric sequence
- linq - How to return a default value if query result is empty
- linq - How to get element at a specified index or a default value
- linq - How to determine whether two sequences are equal
- linq - How to get the single element of a sequence
- linq - How to get single element of a sequence or a default value
- linq - Get single element of a sequence that match condition or a default value
- linq - How to cast elements of a sequence to a given data type