In QTP and vbscript we can create array of dictionary using below syntax/ example.
dim ArrayofDictionary(2)
'Now let us make first element of array as dictionary
Set ArrayofDictionary(0)= createobject("scripting.dictionary")
ArrayofDictionary(0).Add "key1", "temp1"
ArrayofDictionary(0).Add "key2", "temp2"
'Added keys in first dictionary
'Now let us make second element of array as dictionary
Set ArrayofDictionary(1)= createobject("scripting.dictionary")
ArrayofDictionary(1).Add "key1", "temp1"
ArrayofDictionary(1).Add "key2", "temp2"
'Added keys in second dictionary
and so on ............
To access the values inside dictionary, use below syntax.
print ArrayofDictionary(1)("key2")
This is how we can create an array of dictionary to store dictionaries in each element of Array.
More interview questions and answers on arrays in QTP are given below.
dim ArrayofDictionary(2)
'Now let us make first element of array as dictionary
Set ArrayofDictionary(0)= createobject("scripting.dictionary")
ArrayofDictionary(0).Add "key1", "temp1"
ArrayofDictionary(0).Add "key2", "temp2"
'Added keys in first dictionary
'Now let us make second element of array as dictionary
Set ArrayofDictionary(1)= createobject("scripting.dictionary")
ArrayofDictionary(1).Add "key1", "temp1"
ArrayofDictionary(1).Add "key2", "temp2"
'Added keys in second dictionary
and so on ............
To access the values inside dictionary, use below syntax.
print ArrayofDictionary(1)("key2")
This is how we can create an array of dictionary to store dictionaries in each element of Array.
More interview questions and answers on arrays in QTP are given below.
- What is the difference between dictionary and array in QTP?
- How to create dynamic 2 dimensional array in QTP?
- How to sort array of strings in qtp?
- How to create array of dictionary in qtp?
- How to define or declare array in qtp?
- How to return array from function in qtp?
- How to find the length of array in qtp?
- How to find the size of array in qtp?
- Explain the ubound function in qtp.
- Explain the split function in qtp with example.
- What is dotnetfactory object in qtp?
No comments:
Post a Comment
Please Leave your reply. We value your feedback and inputs