ASP Key Property
Last Updated :
19 Mar, 2021
The ASP Key Property is used to change an existing key-value pair to a new key-value in a Dictionary Object.
Syntax:
DictionaryObject.Key(key)=newkey
Parameters: This method has two parameters as mentioned above and discussed below:
- Key: It specifies the name of the existing key that has to be changed.
- newkey: It defines the new name of the key. It is a required attribute.
Example:
ASP
<%
Dim dict
'Create a new dictionary
Set dict=Server.CreateObject( "Scripting.Dictionary" )
'Add values to the dictionary
dict.Add "m" , "mouse"
dict.Add "k" , "keyboard"
dict.Add "h" , "headphones"
'Change the key of one of pairs
dict.Key( "h" )= "hd"
'Checking the new key
Response.Write( "Value of changed key 'hd' is: " & dict.Item( "hd" ))
%>
|
Output:
"Value of changed key 'hd' is: headphones
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...