How to append one dictionary to another

Hi,

I have two dictionaries Config 1 and Config 2.

I’m trying to append Config 2 to Config 1, I found c# code in online

dictionaryFrom.ToList().ForEach(x => dictionaryTo.Add(x.Key, x.Value));

how can I implement this in UIPath

Thanks in advance.

1 Like

You can use For Each Activity to append the dictionary.

Set item type to dictionary object in the properties panel.

For Each item in Dictionary2
       Dictionary1.Add(item.Key,item.Value)

Hi,
use an assign activity then try the following code,
dictionaryFrom.ToList().ForEach(Function(x) dictionaryTo.Add(x.Key, x.Value))

2 Likes

Capture1

Capture2

But It’s not returning any value We can’t use Assign activity here.

dictionary1.Union(dictionary2).ToDictionary(Function (k) k.Key, function(v) v.Value)

I am combining both dictionary and put all values into dictionary1 inside an assign activity.

2 Likes