Linq Skip Operator - How to get a sequence that skips a given number of items
LinqSkipOperator.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 = { "Sternfrucht", "Syzygium jambos", "Wild mangosteen", "Yaca", "Zoetzak", "Witte druif" };
IEnumerable<string> val = (from f in fruits
select f).Skip(2);
Label1.Text = "Fruits List: <br />";
foreach (string names in fruits)
{
Label1.Text += names.ToString() + "<br />";
}
Label2.Text = "After Calling Skip(2) Operator: <br />";
foreach (string n in val)
{
Label2.Text += n.ToString() + "<br />";
}
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>Linq Skip Operator - How to get a sequence that skips a given number of items</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<h2 style="color:DarkBlue; font-style:italic;">
Linq Standard Query Operator: Partitioning Operator - Skip
<br />How to get a sequence that skips a given number of items
</h2>
<hr width="550" 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="Indigo"
Font-Italic="true"
>
</asp:Label>
<br />
<asp:Button
ID="Button1"
runat="server"
OnClick="Button1_Click"
Text="Test Linq Query Operator - Skip"
Height="45"
Font-Bold="true"
ForeColor="DodgerBlue"
/>
</div>
</form>
</body>
</html>
- linq - How to count items of a sequence
- linq - How to sort a sequence in descending order
- linq - How to sort elements of a sequence in ascending order
- linq - How to determine if all items in a sequence match condition
- linq - How to determine if any items in a sequence match condition
- linq - How to determine if a sequence contains a specific element
- 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 - How to get the last element of a sequence