ArrayList RemoveAt() method in asp.net c#

ArrayList RemoveAt() Method
.Net framework ArrayList RemoveAt() method allow us to remove the element at the specified index of the ArrayList. this arraylist RemoveAt() method exists in System.Collections namespace. the RemoveAt() method require to pass a parameter named 'index'.

the 'index' parameter value type is System.Int32. this integer value represents the zero-based index of the element to remove from arraylist. the arraylist RemoveAt() method implements as IList.RemoveAt(Int32).

RemoveAt() method throw ArgumentOutOfRangeException, if the 'index' is less than zero or the 'index' is equal to or greater than Count. arraylist RemoveAt() method also throw NotSupportedException exception, if the arraylist is read-only or the arraylist has a fixed size.

the following asp.net c# example code demonstrate us how can we remove an element at the specified index of the arraylist programmatically at run time in an asp.net application.
ArrayListRemoveAtMethod.aspx

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

<!DOCTYPE html>

<script runat="server">
    protected void Button1_Click(object sender, System.EventArgs e)
    {
        ArrayList colors = new ArrayList() { "WhiteSmoke", "Wheat", "SteelBlue", "SlateGray", "Thistle" };

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

        colors.RemoveAt(3);

        Label1.Text += "<br /><br />After Call RemoveAt(index 3) Method";
        Label1.Text += "<br />Now ArrayList Elements....";
        Label1.Text += "<font color=Tomato>";
        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 remove the element at the specified index of the ArrayList</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <h2 style="color:MidnightBlue; font-style:italic;">
            System.Collections.ArrayList RemoveAt() Method
            <br /> How to remove the element at the specified index of the ArrayList
        </h2>
        <hr width="665" align="left" color="Navy" />
        <br />
        <asp:Label
             ID="Label1"
             runat="server"
             ForeColor="Orchid"
             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 RemoveAt() Method"
            Height="45"
            Font-Bold="true"
            ForeColor="DodgerBlue"
            />
    </div>
    </form>
</body>
</html>
More asp.net examples