how to Read data from dictionary which I have initialized like
variable1= new Dictionary(Of String, String)From {{“0”, “string”}, {“1”, “string2”}}
how to Read data from dictionary which I have initialized like
variable1= new Dictionary(Of String, String)From {{“0”, “string”}, {“1”, “string2”}}
Dictionary_Loop.xaml (6.7 KB)
@vvaidya,
may I know why System.Collections.Generic.KeyValuePair used instead of Dictionary in FOR loop’s Argument type?
Thanks in advance
Hi There…
could you please explain me a simple example of Add_To_Dictionary and Get_From_Dictionary…and how to set Key and Values
Hi @DK_1994,
Before adding items to the dictionary it must be initialized. The default value of the Dictionar object is Nothing.
To initialize it you can use an Assign activity or define default value in the Variables pane.
The value should be new Dictionary(Of String, String), if both your key and value are strings.
Use “Add to Dictionary” activity to add the Key and value in the Dictionary.
Get the value from the Dictionary is easy.
Dict(“keyname”)
Regards,
Arivu
sorry but,how to initialize the dictionary…means …I know the structure and syntax…but no idea about it…how to change it as per requirement…
thanks for above reply
Hi @DK_1994,
Based on your requirement you can assign.
For example if you are using key value pair as string and value also string
Dictionary dict= new Dictionary(Of string,string)
Regards,
Arivu
for using key-value make correct you are using correct dictionary
Incorrect: System.Collections.Generic.Dictionary<System.String, System.String>
Correct: System.Collections.Generic.KeyValuePair<System.String, System.String>
Hey, what is the difference between the the two dictionaries? And why would u use one over the other?
Regarding the dictionary (not key value pair), if it was in a for loop (PrefNames is the dict) like in the picture, how would I write the value of each object in the dict?
Currently, it reads out the entire object (key and value) like so: “[key1, value1]”
Also, how do u add to the keyValuePair, since the ‘add to dictionary’ activity doesn’t work on it.
Thank you.