ASP Contents.Remove 方法

Contents.Remove 方法从 Contents 集合中删除一个项目。

语法

  1. Application.Contents.Remove(name|index)
  2.  
  3. Session.Contents.Remove(name|index)
参数 描述
name 要删除的项目的名称。
index 要删除的项目的索引号。

针对 Application 对象的实例

实例 1

  1. <%
  2. Application("test1")=("First test")
  3. Application("test2")=("Second test")
  4. Application("test3")=("Third test")
  5.  
  6. Application.Contents.Remove("test2")
  7.  
  8. for each x in Application.Contents
  9. Response.Write(x & "=" & Application.Contents(x) & "<br />")
  10. next
  11. %>

输出:

  1. test1=First test
  2. test3=Third test

实例 2

  1. <%
  2. Application("test1")=("First test")
  3. Application("test2")=("Second test")
  4. Application("test3")=("Third test")
  5.  
  6. Application.Contents.Remove(2)
  7.  
  8. for each x in Application.Contents
  9. Response.Write(x & "=" & Application.Contents(x) & "<br />")
  10. next
  11. %>

输出:

  1. test1=First test
  2. test3=Third test

针对 Session 对象的实例:

实例 1

  1. <%
  2. Session("test1")=("First test")
  3. Session("test2")=("Second test")
  4. Session("test3")=("Third test")
  5.  
  6. Session.Contents.Remove("test2")
  7.  
  8. for each x in Session.Contents
  9. Response.Write(x & "=" & Session.Contents(x) & "<br />")
  10. next
  11. %>

输出:

  1. test1=First test
  2. test3=Third test

实例 2

  1. <%
  2. Session("test1")=("First test")
  3. Session("test2")=("Second test")
  4. Session("test3")=("Third test")
  5.  
  6. Session.Contents.Remove(2)
  7.  
  8. for each x in Session.Contents
  9. Response.Write(x & "=" & Session.Contents(x) & "<br />")
  10. next
  11. %>

输出:

  1. test1=First test
  2. test3=Third test