ArrayList ReadOnly() method in asp.net c#

ArrayList IsReadOnly property and ReadOnly() method
ArrayListIsReadOnlyProperty.aspx

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

<!DOCTYPE html>

<script runat="server">
    protected void Button1_Click(object sender, System.EventArgs e)
    {
        ArrayList colors = new ArrayList() { "Salmon", "SandyBrown", "Gray" };

        Label1.Text = "<font color=DodgerBlue>'colors' ArrayList Elements... ";
        foreach (string color in colors)
        {
            Label1.Text += "<br />" + color;
        }
        Label1.Text += "</font>";

        ArrayList readOnlyColors = ArrayList.ReadOnly(colors);

        Label1.Text += "<br /><br />Is 'colors' ArrayList ReadOnly? " + colors.IsReadOnly.ToString();
        Label1.Text += "<br />Is 'readOnlyColors' ArrayList ReadOnly? " + readOnlyColors.IsReadOnly.ToString();

        colors.Add("White");

        //Uncomment this line to get error message.
        //readOnlyColors.Add("White");

        Label1.Text += "<br /><br /><font color=DodgerBlue>After Adding 'White', Now 'colors' ArrayList Elements... ";
        foreach (string color in colors)
        {
            Label1.Text += "<br />" + color;
        }
        Label1.Text += "</font>";
    }
</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>How to create a read-only copy of the ArrayList</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <h2 style="color:MidnightBlue; font-style:italic;">
            System.Collections.ArrayList IsReadOnly Property
            <br /> How to create a read-only copy of the ArrayList
        </h2>
        <hr width="525" align="left" color="Navy" />
        <br />
        <asp:Label
             ID="Label1"
             runat="server"
             ForeColor="HotPink"
             Font-Size="Large"
             Font-Names="Courier New"
             Font-Italic="true"
             Font-Bold="true"
             >
        </asp:Label>
        <br /><br />
        <asp:Button 
            ID="Button1"
            runat="server"
            OnClick="Button1_Click"
            Text="Test ArrayList IsReadOnly Property"
            Height="45"
            Font-Bold="true"
            ForeColor="DodgerBlue"
            />
    </div>
    </form>
</body>
</html>
More asp.net examples