HttpApplicationState.RemoveAt Method (Int32)


The .NET API Reference documentation has a new home. Visit the .NET API Browser on to see the new experience.

Removes an HttpApplicationState object from a collection by index.

Namespace:   System.Web
Assembly:  System.Web (in System.Web.dll)

public void RemoveAt(
	int index


Type: System.Int32

The position in the collection of the item to remove.

The following code example demonstrates how to insert two application variables into the collection, and then use the RemoveAt method to remove the first variable in a custom HttpApplicationState object.

<%@ Page language="c#" AutoEventWireup="true" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
<html xmlns="" >
    <title>HttpApplicationState - RemoveAt - C# Example</title>
    <script runat="server">
      void Page_Load(Object sender, EventArgs e) 
          // Add two new application state variables.
          Application.Add("City", "Redmond");
          Application.Add("State", "WA");

          // Show the contents of both application state variables.
          Label1.Text = "Application.Keys[0] contains: " + Application.Keys[0].ToString();
          Label1.Text += "<br />Application.Keys[1] contains: " + Application.Keys[1].ToString();

          // Remove the City application state variable, which is at
          // the first index location.
          Label2.Text = "<br />Call:&nbsp; Application.RemoveAt(0)";

          // Show the contents of the application state variable,
          // in the first index location, which is now the State variable.
          Label3.Text = "<br />Application.Keys[0] contains: " + Application.Keys[0].ToString();
    <form id="Form1" method="post" runat="server">
            <h3>HttpApplicationState - RemoveAt - C# Example</h3>
      <asp:Label id="Label1" runat="server" /><br />
      <asp:Label id="Label2" runat="server" /><br />
      <asp:Label id="Label3" runat="server" />

.NET Framework
Available since 1.1
Return to top