c# - How to display a range of items from an array

Display array range
display-array-range.aspx

<%@ Page Language="C#" AutoEventWireup="true"%>  
  
<!DOCTYPE html>  
<script runat="server">  
    protected void Button1_Click(object sender, System.EventArgs e)  
    {
        string[] birds = new string[]
        {
            "Laughing Gull",
            "Caspian Tern",
            "Arctic Tern",
            "Roseate Tern",
            "Sooty Tern",
            "Black Tern",
            "Black Skimmer",
            "Great Skua"
        };

        Label1.Text = "birds array elements.........<br />";
        for (int i = 0; i < birds.Length; i++)
        {
            Label1.Text += birds[i] + "<br />";
        }

        Label1.Text += "<br />birds array elements [index range 1 to 4].........<br />";
        for (int i = 1; i <= 4; i++)
        {
            Label1.Text += birds[i] + "<br />";
        }

        Label1.Text += "<br />birds array elements [index range 3 to 5].........<br />";
        for (int i = 3; i <= 5; i++)
        {
            Label1.Text += birds[i] + "<br />";
        }
    }  
</script>  
  
<html xmlns="http://www.w3.org/1999/xhtml">  
<head id="Head1" runat="server">  
    <title>c# example - display array range</title>  
</head>  
<body>  
    <form id="form1" runat="server">  
    <div>  
        <h2 style="color:DarkBlue; font-style:italic;">  
            c# example - display array range
        </h2>  
        <hr width="550" align="left" color="LightBlue" />    
        <asp:Label   
            ID="Label1"   
            runat="server"  
            Font-Size="Large"  
            >  
        </asp:Label>  
        <br />
        <asp:Button   
            ID="Button1"   
            runat="server"   
            Text="display array range"  
            OnClick="Button1_Click"
            Height="40"  
            Font-Bold="true"  
            />  
    </div>  
    </form>  
</body>  
</html>
More c# examples