ArrayList Reverse() method in asp.net c#

ArrayList Reverse() Method
.Net framework ArrayList.Reverse() method allow us to reverse the order of the elements in the entire ArrayList. this arraylist Reverse() method exists in System.Collections namespace. this method has no optional or required parameter.

Reverse() method throw NotSupportedException exception, if the arraylist is read-only. the Reverse() method uses Array.Reverse to reverse the order of the arraylist elements order.

the following asp.net c# example code demonstrate us how can we reverse the arraylist elements order programmatically at run time in an asp.net application.
ArrayListReverseMethod.aspx

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

<!DOCTYPE html>

<script runat="server">
    protected void Button1_Click(object sender, System.EventArgs e)
    {
        ArrayList colors = new ArrayList() { "DarkTurquoise", "DeepSkyBlue", "DarkGreen", "Fuchsia", "GainsBoro" };

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

        colors.Reverse();

        Label1.Text += "<br /><br />After Call Reverse() Method";
        Label1.Text += "<br />Now ArrayList Elements....";

        Label1.Text += "<font color=Crimson>";
        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 reverse order of the elements in the entire ArrayList</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <h2 style="color:MidnightBlue; font-style:italic;">
            System.Collections.ArrayList Reverse() Method
            <br /> How to reverse the order of the elements in the entire ArrayList
        </h2>
        <hr width="610" align="left" color="Navy" />
        <br />
        <asp:Label
             ID="Label1"
             runat="server"
             ForeColor="DarkSlateBlue"
             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 Reverse() Method"
            Height="45"
            Font-Bold="true"
            ForeColor="DodgerBlue"
            />
    </div>
    </form>
</body>
</html>
More asp.net examples