What is a Dictionary?
In general, a Dictionary is a collection of words and their Meanings/Definitions.
In the same Dictionary in any programming language is a collection of Keys and Values, where “Key” is equivalent to Words and “Value” is equivalent to Meanings/Definitions.
The Dictionary<TKey, TValue>
is a generic collection class available in the System.Collection.Generics namespace. Here “TKey” denotes the type of key and “TValue” is the type of TValue.
Example
Implementation using UiPath :
Let us implement a workflow to achieve the below functionalities
Major Steps That We Will Implement:
1. Defining a Dictionary
2. Adding items to the Dictionary
3. Accessing items from the Dictionary
Step 1:
Drag “Assign” activity into the designer panel and define the dictionary.
my_Dictionary = new Dictionary(Of String, String)
Here my_Dictionary is of System.Collection.Generics.Dictionary<String, String> type
Step 2:
Drag “Invoke Method” activity into the designer panel to add items to the Dictionary.
Example:
Key: INDIA
Value: New Delhi
Step 3:
Another way of adding items Dictionary is by using Microsoft.Activities.Extensions package.
Drag “Add to dictionary” activity into the designer panel to add items to the Dictionary.
Example:
Key: USA
Value: Washington, D.C
Step 4:
Drag “Message Box” activity to display the first added Key and Value pair
i.e. Find the Value of the Key “INDIA”
Step 5:
Drag “Message Box” activity to display the second added Key and Value pair.
i.e. Find the Value of the Key “USA”
Step 6:
Finally, execute the workflow 🙂
Click here to download the Source Code…
Hope it has helped you…