asp中Dictionary(數據字典)的使用

轉載地址: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()     刪除全部鍵/條目對
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章