Dictionary Storage

Hi Team,

I am completely new to dictionary. I wanted to know how to

  1. Create a dictionary
  2. Store Address (Contains 5 lines)
  3. How to access the same from dictionary.

lets go one by one

in variable panel create a variable named like
dict_input with datataype as System.Collections.Generic.Dictionary(string, string) and to get the type we can click on BROWSE FOR TYPE and then search this type
and default value as New Dictionary(of string, string)

to store value in it
use a SIMPLE assign activity like this
dict_input(“keyname”) = "yourvalue"
as dictionary is a pair of key and value like this
we can mention the key name in left side and value in right side of assign activity

then finally

to access them
in writeline activity like this

hope this would help you
Cheers @Robotics

I extracting the address as below
ForEach [Item] in [NameSplit]

How to add the above in dict_input(“keyname”) = “yourvalue”?

I have declared as in Argument
out_dict - out - Dictionary<String,String>
Let me know where do i need to do the changes ?

Hey @Robotics (what a cool name :smile:)

@Palaniyappan explained the use of dictionairy perfectly. I just want to add that there is a workflow in the ReFramework (InitAllSettings.xaml) that creates a dictionairy from values stored in an excel file (usually called Config).

And because this came up before today: you can also store more than one value per key in a dictionairy :wink:

Cheers, Lukas

in a ASSIGN activity

Cheers @Robotics

I am asking how to do in assign activity.
out_dict = item ?

fine if you want to store your name in the dictionary variable created
then in assign activity
dict_input(“Name”) = "Robotics"
where dict_input is a variable of type System.Collections.Generic.Dictionary(of string, string)

and similarly if we want to save the place you born
then in assign activity
dict_input(“Place”) = "USA"

so now if you want to access the name value in a writeline then mention like this

Cheers @Robotics

Based on the above syntax i am not getting any error but getting the same output. Let me elaborate what i have done so far.

  1. I have address with 5 lines say (Address1, 2, 3, 4, 5)
  2. Using ForEach (Item) in (NameSplit)
  3. Using Message Box with Item. Displaying each and every line correctly.
  4. Now inside the loop i have
    out_dict = new Dictionary(of String, String)
    out_Dict(“Address1”) = item.ToString.Trim
    out_Dict(“Address2”) = item.ToString.Trim
    out_Dict(“Address3”) = item.ToString.Trim
    out_Dict(“Address4”) = item.ToString.Trim
    out_Dict(“Address5”) = item.ToString.Trim
  5. I am expecting the each 5 lines should be stored in respective Address1…5
    But in message box - out_Dict(“Address1”).ToString
    The above message box should display only address1 that is first line.
    But in each loop displaying five lines. how to give the condition which displays each address1…5 shuld display each address line ?

we need to create this dictionary before the for each loop
else it will create new dictionary for every loop thats the issue
Cheeers @Robotics