Linq Max Operator - How to get the maximum number of a sequence of numbers
LinqMaxOperator.aspx
<%@ Page Language="C#" AutoEventWireup="true" %>
<%@ Import Namespace="System.Linq" %>
<!DOCTYPE html>
<script runat="server">
protected void Button1_Click(object sender, System.EventArgs e)
{
int[] myNums = {27,26,19,56,47,23,33};
Label1.Text = "Numbers List: <br />";
foreach (int n in myNums)
{
Label1.Text += n.ToString() + "<br />";
}
Label2.Text = "Maximum Value in Numbers: " + myNums.Max().ToString(); ;
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>Linq Max Operator - How to get the maximum number of a sequence of numbers</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<h2 style="color:DarkBlue; font-style:italic;">
Linq Standard Query Operator - Max
<br />How to get the maximum number
<br /> of a sequence of numbers
</h2>
<hr width="375" align="left" color="CornFlowerBlue" />
<asp:Label
ID="Label1"
runat="server"
Font-Size="X-Large"
ForeColor="IndianRed"
Font-Italic="true"
>
</asp:Label>
<br />
<asp:Label
ID="Label2"
runat="server"
Font-Size="X-Large"
ForeColor="DodgerBlue"
Font-Italic="true"
>
</asp:Label>
<br /><br />
<asp:Button
ID="Button1"
runat="server"
OnClick="Button1_Click"
Text="Test Linq Query Operator - Max"
Height="45"
Font-Bold="true"
ForeColor="DodgerBlue"
/>
</div>
</form>
</body>
</html>
- linq - How to count items of a sequence
- linq - How to get minimum value from a numeric sequence
- linq - How to sort a sequence in descending order
- linq - How to reverse the order of elements in a sequence
- linq - How to get a sequence that skips a given number of items
- linq - Get a subset of sequence that skips unmatched condition items
- linq - How to get element at a specified index in a sequence
- linq - How to get the first element of a sequence
- linq - Get first element of a sequence that match condition
- linq - How to get first element of a sequence or a default value