Phương thức ASP Contents.Remove

Sách tham khảo đối tượng Application

Phương thức Contents.Remove xóa một mục trong bộ Collections.

Cú pháp

Application.Contents.Remove(name|index)
Session.Contents.Remove(name|index)
Tham số Mô tả
name Tên của mục cần xóa.
index Số chỉ mục của mục cần xóa.

Đối tượng instance cho Application

Mô hình 1

<%
Application("test1")=("First test")
Application("test2")=("Second test")
Application("test3")=("Third test")
Application.Contents.Remove("test2")
for each x in Application.Contents
 Response.Write(x & "=" & Application.Contents(x) & "<br />")
next
%>

Kết quả xuất ra:

test1=First test
test3=Third test

Mô hình 2

<%
Application("test1")=("First test")
Application("test2")=("Second test")
Application("test3")=("Third test")
Application.Contents.Remove(2)
for each x in Application.Contents
 Response.Write(x & "=" & Application.Contents(x) & "<br />")
next
%>

Kết quả xuất ra:

test1=First test
test3=Third test

Đối tượng instance cho Session:

Mô hình 1

<%
Session("test1")=("First test")
Session("test2")=("Second test")
Session("test3")=("Third test")
Session.Contents.Remove("test2")
for each x in Session.Contents
 Response.Write(x & "=" & Session.Contents(x) & "<br />")
next
%>

Kết quả xuất ra:

test1=First test
test3=Third test

Mô hình 2

<%
Session("test1")=("First test")
Session("test2")=("Second test")
Session("test3")=("Third test")
Session.Contents.Remove(2)
for each x in Session.Contents
 Response.Write(x & "=" & Session.Contents(x) & "<br />")
next
%>

Kết quả xuất ra:

test1=First test
test3=Third test

Sách tham khảo đối tượng Application