How to add values to a Key Value Pair collection type?

How can I add a record to Key Value pair collection type? In Dictionary, you can use ‘Add to dictionary’ method but I am not able to find similar method for Key Value Pair collection type? I want to run a for each loop through all the items in collection and print key value pair.

1 Like

You have the constructor for the same,

new KeyValuePair(key, value)



Hope the following helps you.


1 Like


Please have a view on this similar topic

Cheers @aditi1

Hello @aditi1

Below video might help you:-

Mark as a solution and like it if this helps you :slight_smile:

Happy Automation :raised_hands:

Best Regards
Er Pratik Wavhal :robot::man_technologist:t4: :computer:

@Pratik_Wavhal I have already used this method but this is for dictionary. I am using key value pair in my script which is different from dictionary.
System.Collections.Generic.KeyValuePair<String, String>

@Palaniyappan I had already seen this post and tried to use this yourdicitionaryvariable(“yourkeyname”) = “yourvalue” but it didn’t work for me. It throws me an error. I am using C# in my script not VB and this is not supported in C#.

Thanks @Yoichi . I was close to this only and you post just helped me.

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