c# - How to compare two string arrays

Compare string arrays
linq-compare-string-arrays.aspx

<%@ Page Language="C#" AutoEventWireup="true"%>  
  
<!DOCTYPE html>  
<script runat="server">  
    protected void Button1_Click(object sender, System.EventArgs e)  
    {
        string[] colors = { "red", "blue", "green", "yellow" };
        string[] colors2 = { "crimson", "pink", "hotpink", "darkred" };
        string[] colors3 = { "red", "blue", "green", "yellow" };

        Label1.Text = "Colors: ";
        foreach(string s in colors)
        {
            Label1.Text += s + " | ";
        }
        Label1.Text += "<br />Colors2: ";
        foreach(string s in colors2)
        {
            Label1.Text += s + " | ";
        }
        Label1.Text += "<br />Colors3: ";
        foreach(string s in colors3)
        {
            Label1.Text += s + " | ";
        }
        Boolean result = colors.SequenceEqual(colors2);
        Label1.Text += "<br /><br />Colors = Colors2? " + result.ToString();

        Boolean result2 = colors.SequenceEqual(colors3);
        Label1.Text += "<br /><br />Colors = Colors3? " + result2.ToString();
    }  
</script>  
  
<html xmlns="http://www.w3.org/1999/xhtml">  
<head id="Head1" runat="server">  
    <title>c# linq example - compare string arrays</title>  
</head>  
<body>  
    <form id="form1" runat="server">  
    <div>  
        <h2 style="color:DarkBlue; font-style:italic;">  
            c# linq example - compare string arrays
        </h2>  
        <hr width="550" align="left" color="LightBlue" />    
  
        <asp:Label   
            ID="Label1"   
            runat="server"  
            Font-Size="Large"  
            >  
        </asp:Label>  
        <br /><br />
        <asp:Button   
            ID="Button1"   
            runat="server"   
            Text="compare string arrays"  
            OnClick="Button1_Click"
            Height="40"  
            Font-Bold="true"  
            />  
    </div>  
    </form>  
</body>  
</html>
More c# examples