c# - How to initialize a two dimensional array

Initializing two dimensional array
TwoDimensionStringArray.aspx

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

<!DOCTYPE html>

<script runat="server">

    protected void Button1_Click(object sender, System.EventArgs e)
    {
        string[,] colorArray = { { "AliceBlue", "#F0F8FF" }, { "AntiqueWhite", "#FAEBD7" }, { "Aqua", "#00FFFF" }, { "Azure", "#F0FFFF" } };
        Label1.Text = "Two dimensional String array created successfully!<br />Array elements:<br /><br /><i>";
        int rows = colorArray.GetUpperBound(0);
        int columns = colorArray.GetUpperBound(1);
        Label2.Text = "";

        for (int currentRow = 0; currentRow <= rows; currentRow++)
        {
            for (int currentColumn = 0; currentColumn <= columns; currentColumn++)
            {
                Label2.Text += colorArray[currentRow, currentColumn];
                Label2.Text += " ";
            }
            Label2.Text += "<br />";
        }
        
    }
</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>How to create two dimension string array in asp.net</title>
</head> 
<body>
    <form id="form1" runat="server">
    <div>
        <h2 style="color:Navy">asp.net array example: Two Dimension String Array</h2>
        <asp:Label 
             ID="Label1" 
             runat="server" 
             Font-Size="Large"
             ForeColor="HotPink"
             Font-Bold="true"
             Font-Italic="true"
             >
        </asp:Label>
        <br />
        <asp:Label 
             ID="Label2" 
             runat="server" 
             Font-Size="Large"
             ForeColor="SeaGreen"
             Font-Bold="true"
             Font-Italic="true"
             >
        </asp:Label>
        <br /><br />
        <asp:Button 
             ID="Button1" 
             runat="server" 
             OnClick="Button1_Click"
             Font-Bold="true"
             Text="Create Two Dimensional String Array"
             ForeColor="DarkBlue"
             />   
    </div>
    </form>
</body>
</html>
More c# examples