ASP Exists 方法

定義和用法

Exists 方法返回在 Dictionary 對象中是否存在指定的 key 的布爾值。如果存在,返回 true,否則返回 false。

語法:

DictionaryObject.Exists(key)
參數 描述
key 必需的。需搜索的 key 值。

實例

<%
dim d
set d=Server.CreateObject("Scripting.Dictionary")
d.Add "c","China"
d.Add "i","Italy"
d.Add "s","Sweden"
if d.Exists("c")=true then
  Response.Write("Key exists!")
else
  Response.Write("Key does not exist!")
end if
set d=nothing
%>

輸出:

Key exists!