c# - How to initialize an int array

Initialize an int array
IntArray.aspx

<%@ Page Language="C#" %>

<!DOCTYPE html>

<script runat="server">

    protected void Button1_Click(object sender, System.EventArgs e)
    {
        Label1.Text = "Int array created successfully!<br />Array element is: ";
        int[] myNumbers = {1,2,3,4,5,6,7,8 };
        foreach (int element in myNumbers)
        { 
            Label1.Text += element.ToString()+" ";
        }
    }
</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>How to create an int array in asp.net</title>
</head> 
<body>
    <form id="form1" runat="server">
    <div>
        <h2 style="color:Fuchsia">asp.net array example: Int Array</h2>
        <asp:Label 
             ID="Label1" 
             runat="server" 
             Font-Size="Large"
             ForeColor="OrangeRed"
             Font-Bold="true"
             Font-Italic="true"
             >
        </asp:Label>
        <br /><br />
        <asp:Button 
             ID="Button1" 
             runat="server" 
             OnClick="Button1_Click"
             Font-Bold="true"
             Text="Create Int Array"
             ForeColor="DarkGreen"
             />   
    </div>
    </form>
</body>
</html>
More c# examples