ASP中Dictionary的使用

ASP中Dictionary的使用

  Dictionary ,字典,是一种集合(collection)。多用与储存较多数据,无惧上传类,喳喳鸟聊天室中有相关应用

用法如下:

Set Session("user")=Server.createObject("Scripting.Dictionary") '创建

Session("user").Add "name",username '添加

s=Session("user")("name") '取得值

blnIsThere=Session("user").Exists("name") '是否存在键name 返回boolean值

Session("user")("name")=username1 '更改值

REM 遍历

for each keys in Session("user")
Response.Write(keys)'得到所有键
Response.Write(Session("user")(keys)) '取得所有值
next

Session("user").Remove("name") '移除

Session("user").RemoveAll '移除所有

Dictionary对象

属性和说明
CompareMode    (仅用于VBScript)设定或返回键的字符串比较模式
Count    只读。返回Dictionary里的键/条目对的数量
Item(key)    设定或返回指定的键的条目值
Key(key)    设定键值

方 法与 说 明
Add(key,item)    增加键/条目对到Dictionary
Exists(key)    如果指定的键存在,返回True,否则返回False
Items()    返回一个包含Dictionary对象中所有条目的数组
Keys()    返回一个包含Dictionary对象中所有键的数组
Remove(key)    删除一个指定的键/条目对
RemoveAll()    删除全部键/条目对
轉自:http://www.25175.com/200609/25175/25175_html/2007-05/1706.html

http://www.google.com/search?hl=zh-TW&q=asp%E4%B8%AD%E4%BD%BF%E7%94%A8Scripting.Dictionary&btnG=Google+%E6%90%9C%E5%B0%8B&lr=

申明

非源创博文中的内容均收集自网上,若有侵权之处,请及时联络,我会在第一时间内删除.再次说声抱歉!!!

博文欢迎转载,但请给出原文连接。

原文地址:https://www.cnblogs.com/Athrun/p/1178836.html