Dictionary Key and Values to display in a message box



I have a variable of data type dictionary(string,object).


I would like to print all the key value pairs inside the dictionary into a Single message box for display.

I was once able to do it using array conversion, and the print out has something like { key 1, value 1},{key 2, value 2), {key 3, value 3}…{key infinity, value infinity}, but alas! The secret has disappear from my brain!


Methods tried include direct ToString conversion, looping and concatenating all pairs in a single line, conversion to array and printing that, data table conversion and outputting as data table, etc etc. I failed in all of them. Other forum suggestions of similar nature have failed me too.

I am reaching out to the community and pooling all the available answers in a single forum post so that future users won’t have to go through the frustration I have faced. So please, give it your best shot and post all possible answers that is usable in the latest UiPath version (version 7).

Please also include all the necessary packages, .net framework, dependencies etc etc I may need to make your method succeed so that we all can have multiple pathways to the same answer.

Also, if you are able to allocate for multiple dictionary types (such as dictionary(string, string) or dictionary(array, string) etc etc) and in how to print it, that will be more than excellent!

I won’t be posting a sample of the workflow as the sample is the RE_Framework_Template available.

I look forward to your replies in a week or month! :smiley:


So uipath close my thread in 3 days. I have to post my thanks over here.


Ok , so all of the answers are valid(other than minor error), thus I am marking any particular one as the ‘solution’. I will summarise the ‘correct’ answer for future users to view.


Recall that my variable is a dictionary of data type (STRING,OBJECT), with key-value pairs inside it.

  1. For HareeshMR, just make sure the type argument use in the ‘for each’ activity is of System.Collections.Generic.Dictionary<STRING,OBJECT>. Or else, it won’t run.

I will like to note that in his picture reference, he only specifically convert the key to a string.

If you dictionary has key-value of object data type, just type item.ToString during the assignment of values to a variable to convert to string too.

A disclaimer: I haven’t try other data types in a dictionary key pair such as array, object; list,object;etc

  1. For Felipe_Kotinda, he referenced an older post, and shared how to reference specific key/value after converting it to an array.
    To make it work, make sure to set the type argument of the ‘for each’ activity be of object type.

  2. Gluon’s answer is the first time I see the ‘invoke code with vba’ activity. If you know vbnet, you can do whatever you want. In his example he utilised, it work well too.

  3. For ppr, aside from syntax (an extra bracket at the end), his answer works fine. The .ToArray was unnecessary in this case. His worry of ToString not working is also a non-issue, but his suggestion to that possible problem is helpful for further data manipulation.
    The modified answer: String.Join(",", out_config.Select(Function (e) e.Key + “,” + e.Value.ToString + vbcrlf)

Final Note: Thank you all for the answer. I have learnt aplenty from this episode. Till the nxt problem!
Also, please ignore the solved by whoever solution.

Here is a simple example @gabby

If you want to print each key and value you can do that like this :slight_smile:

  1. Selector is a dictionary of type object and string and I changed the item is also a key value pair of object and string. so, i will get both the key and value

  2. If you want to print all the keys and values.

a) Create a variable of type string before looping and
b) Iterate through the same way above and use string manipulations to concatenate both the key and value and then print it after looping


To get elements from specific index, Use,

Does this answer your question?
DisplayDictionary.xaml (4.8 KB)


Lets assume your ok with

  • separating the Key from the value with “:”
  • separating the entries with “;”

Following Statement is giving you a flatten string:
String.Join(",", YourDicitionaryVariable.Select(function (e) e.Key + “:” + e.Value.toString).ToArray))

But keep in mind in case of a dictionary(Of String, Object) the toString Statement maybe is not returning the representation as needed. For this a conversion can be done e.g. with Cast, DirectCast etc.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.