How to access the key or value of a dictionary based on index?

Would like to print the key of a dictionary in a message box.

Would like to print the value of a dictionary in a message box.

Use for each activity. In properties, set Values as your dictionary and TypeArgument to System.Collections.Generic.KeyValuePair<TKey, TValue>
To display key, use item.Key and for value, item.Value properties

If this helps, please mark it as solution so that people facing similar issues can directly navigated to answer.


When trying to type argument of the for each loop I got the following error

Also I need to get the key of the dictionary for a specific index instead of looping through the dictionary.

HI @Aishwarya_Maggi,

You need to specify the Key and Value data types… Check the screenshot below…

1 Like

Hi, thanks for your reply. I have managed to change the data type but I get an error when trying to print the key


For the dictionary key issue, try looking into these two posts… These two gives a good idea on how to loop through the dictionaries…

Let know if it doesn’t help… if it works, please mark the answer as the solution so it will be helpful for others as well :slight_smile:


You have put the argument type to dictionary. it should be System.Collections.Generic.KeyValuePair<TKey, TValue>

To get elements from specific index, Use,


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