asp中Dictionary(数据字典)的使用

来源:互联网 发布:淘宝卖家虚拟发货 编辑:程序博客网 时间:2024/04/27 15:04

转载地址:http://hi.baidu.com/cicon/item/59a05d5d78f68e13abf6d75f

用法如下:


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()     删除全部键/条目对
0 0
原创粉丝点击