ASP 项目属性
ASP 项属性用于返回或设置字典对象中项的值。
句法:
DictionaryObject.Item(key)[=newitem]
参数值:
- key:它指定与项目关联的键。 它是必需的属性。
- newitem:它指定必须为给定键设置的新项目。
示例:下面的代码演示了 ASP Dictionary.Item 属性。
ASP
<%
Dim dict
'Create a new dictionary
Set dict=Server.CreateObject("Scripting.Dictionary")
'Add values to the dictionary
dict.Add "g","green"
dict.Add "r","red"
dict.Add "p","purple"
'Getting a value from the dictionary
Response.Write("Value of key 'p' is: " & dict.Item("p"))
'Setting a new value to the key
dict.Item("p") = "violet"
'Getting the value again from the dictionary
Response.Write("
Value of key 'p' is: " & dict.Item("p"))
%>
输出:
Value of key 'p' is: purple
Value of key 'p' is: violet