Linq Min Operator - How to get the minimum number of a sequence of numbers
LinqMinOperator.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[] numbers = {47,13,16,54,41,32,99};
Label1.Text = "Numbers List: <br />";
foreach (int n in numbers)
{
Label1.Text += n.ToString() + "<br />";
}
Label2.Text = "Minimum Value in Numbers: " + numbers.Min().ToString(); ;
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>Linq Min Operator - How to get the minimum 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 - Min
<br />How to get the minimum 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="Violet"
Font-Italic="true"
>
</asp:Label>
<br />
<asp:Label
ID="Label2"
runat="server"
Font-Size="X-Large"
ForeColor="OliveDrab"
Font-Italic="true"
>
</asp:Label>
<br /><br />
<asp:Button
ID="Button1"
runat="server"
OnClick="Button1_Click"
Text="Test Linq Query Operator - Min"
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 sort a sequence in descending order
- linq - Get first element of a sequence that match condition or a default value
- linq - How to get the last element of a sequence
- linq - Get last element of a sequence that match condition or a default value
- linq - How to take a given number of elements from a sequence
- linq - Get a subset of elements from a sequence that match condition
- linq - How to concatenate two sequences
- linq - How to return a default value if query result is empty