Nested Disctionary Problems

Hello

I have a dictionary, MasterDict, that is of type Dictionary(of String, Dictionary(of String, String)) and is initialized correctly. Then I have a second dictionary, SlaveDict, that is of type Dictionary(of String, String), and is also initialized correctly.

Keys and Values get added to the SlaveDict (about 2 entries, data of people like name and surname etc.). Then after one person’s data has been done in SlaveDict it looks like this for example:
{
name: John
surname: Smith
}

What I want to do then is add this data to MasterDict with the tag of the person such that it ends like this as an example:
{
PersonA:{
name: John
surname: Smith
}

I’ve gotten this to work for the first iteration. But I then need to clear SlaveDict to reset it to put new data in it. My problem is that when I clear, it removes PersonA data from MasterDict even after it has already been added to MasterDict, any help on this?

@Tristan_Kok1
give a try on following:
instead of clearing the dictionary create a new one with new Dictionary(… use this within the iteration and add it later to the masterDict.

PersonA Dict in MasterDict has a reference to the PersonA Dict Variable (by value vs. by reference) and thats why it is cleared in MasterDict as well.

Thanks man that worked!

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