Linq SkipWhile Operator - How to get a sequence that skips items that do not meet an expression
LinqSkipWhileOperator.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[] nums = { 51,210,55,29,125,15,177,50 };
IEnumerable<int> val = nums.OrderBy(n=> n).SkipWhile(n => n<100);
Label1.Text = "Numbers List: <br />";
foreach (int i in nums)
{
Label1.Text += i.ToString() + "<br />";
}
Label2.Text = "After Calling SkipWhile(number<100) Operator: <br />";
foreach (int n in val)
{
Label2.Text += n.ToString() + "<br />";
}
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>Linq SkipWhile Operator - How to get a sequence that skips items that do not meet an expression</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<h2 style="color:DarkBlue; font-style:italic;">
Linq Standard Query Operator: Partitioning Operator - SkipWhile
<br />How to get a sequence that skips items that do not meet an expression
</h2>
<hr width="650" align="left" color="CornFlowerBlue" />
<asp:Label
ID="Label1"
runat="server"
Font-Size="X-Large"
ForeColor="DarkOliveGreen"
Font-Italic="true"
>
</asp:Label>
<br />
<asp:Label
ID="Label2"
runat="server"
Font-Size="X-Large"
ForeColor="DarkOrchid"
Font-Italic="true"
>
</asp:Label>
<br />
<asp:Button
ID="Button1"
runat="server"
OnClick="Button1_Click"
Text="Test Linq Query Operator - SkipWhile"
Height="45"
Font-Bold="true"
ForeColor="DodgerBlue"
/>
</div>
</form>
</body>
</html>
- linq - How to get a sequence that skips a given number of items
- linq - How to get element at a specified index in a sequence
- linq - How to get the first element of a sequence
- linq - How to get last element of a sequence or a default value
- 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 - 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