Freigeben über


HttpApplicationState.RemoveAt-Methode

Entfernt ein HttpApplicationState-Objekt anhand des Indexes aus der Auflistung.

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

Syntax

'Declaration
Public Sub RemoveAt ( _
    index As Integer _
)
'Usage
Dim instance As HttpApplicationState
Dim index As Integer

instance.RemoveAt(index)
public void RemoveAt (
    int index
)
public:
void RemoveAt (
    int index
)
public void RemoveAt (
    int index
)
public function RemoveAt (
    index : int
)

Parameter

  • index
    Die Position des zu entfernenden Elements in der Auflistung.

Beispiel

Im folgenden Codebeispiel wird veranschaulicht, wie zwei Anwendungsvariablen in die Auflistung eingefügt werden. Anschließend wird mithilfe der RemoveAt-Methode die erste Variable in einem benutzerdefinierten HttpApplicationState-Objekt entfernt.

<%@ Page language="VB" AutoEventWireup="true" %>
<HTML>
  <HEAD>
    <title>HttpApplicationState - RemoveAt - VB.NET Example</title>
    <script runat="server">
      Sub Page_Load(sender As Object, e As EventArgs)

          ' 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.
          Application.RemoveAt(0)
          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()
      End Sub
    </script>
  </HEAD>
  <body>
    <form id="Form1" method="post" runat="server">
            <h3>HttpApplicationState - RemoveAt - VB.NET Example</h3>
      <asp:Label id="Label1" runat="server" /><br>
      <asp:Label id="Label2" runat="server" /><br>
      <asp:Label id="Label3" runat="server" />
    </form>
  </body>
</HTML>
<%@ Page language="c#" AutoEventWireup="true" %>
<HTML>
  <HEAD>
    <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.
          Application.RemoveAt(0);
          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();
      }
    </script>
  </HEAD>
  <body>
    <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" />
    </form>
  </body>
</HTML>

Plattformen

Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

.NET Framework unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.

Versionsinformationen

.NET Framework

Unterstützt in: 2.0, 1.1, 1.0

Siehe auch

Referenz

HttpApplicationState-Klasse
HttpApplicationState-Member
System.Web-Namespace