Linq SequenceEqual Operator - How to compare two sequences to see if they are equivalent
LinqSequenceEqualOperator.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[] fruitsList1 = { "Citrus sinensis", "Diospyros blancoi", "Coconut palm" };
string[] fruitsList2 = { "Jambosa jambos", "Korean mango", "Malabar plum" };
string[] fruitsList3 = { "Citrus sinensis", "Diospyros blancoi", "Coconut palm" };
Label1.Text = "Fruits List 1:....... <br />";
foreach (string names in fruitsList1)
{
Label1.Text += names.ToString() + "<br />";
}
Label1.Text += "<br />Fruits List 2:....... <br />";
foreach (string names in fruitsList2)
{
Label1.Text += names.ToString() + "<br />";
}
Label1.Text += "<br />Fruits List 3:....... <br />";
foreach (string names in fruitsList3)
{
Label1.Text += names.ToString() + "<br />";
}
Label2.Text = "After Calling SequenceEqual Operator [fruitsList1.Equals(fruitsList2)]: " + fruitsList1.SequenceEqual(fruitsList2);
Label2.Text += "<br />After Calling SequenceEqual Operator [fruitsList1.Equals(fruitsList3)]: " + fruitsList1.SequenceEqual(fruitsList3);
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>Linq SequenceEqual Operator - How to compare two sequences to see if they are equivalent</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<h2 style="color:DarkBlue; font-style:italic;">
Linq Standard Query Operator - SequenceEqual
<br />How to compare two sequences to see if they are equivalent
</h2>
<hr width="575" align="left" color="CornFlowerBlue" />
<asp:Label
ID="Label1"
runat="server"
Font-Size="X-Large"
ForeColor="SeaGreen"
Font-Italic="true"
>
</asp:Label>
<br />
<asp:Label
ID="Label2"
runat="server"
Font-Size="X-Large"
ForeColor="DarkMagenta"
Font-Italic="true"
>
</asp:Label>
<br />
<asp:Button
ID="Button1"
runat="server"
OnClick="Button1_Click"
Text="Test Linq Query Operator - SequenceEqual"
Height="45"
Font-Bold="true"
ForeColor="DodgerBlue"
/>
</div>
</form>
</body>
</html>
- linq - How to determine if any items in a sequence match condition
- linq - How to determine if a sequence contains a specific element
- linq - How to get a sequence without duplicate items
- 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 last element of a sequence that match condition
- linq - How to get last element of a sequence or a default value
- linq - How to generate a list with a specific range of numbers
- linq - How to repeat an item to generate a sequence
- linq - How to get the single element of a sequence