I’m using C# and am trying to learn how to create a dictionary using a config file, but I’ve reached a point where I’m stuck and really need some help!
I’ve created a very basic test config file using a spreadsheet ‘config.xlsx’:
I’ve initialised a dictionary ‘Out_Config’, assigned a string variable for the config file path and another string variable for the sheet name within the config file. I’ve used a Read Range Workbook activity to create datatable dtConfigTable.
I’m then using a ‘For Each Row in Data Table’ activity:
I’m then using a message box, thinking it will display the value:
When I run it, I get this error:
I know I’m missing a step somewhere, more than likely somewhere in the ‘For Each Row’ activity, but I don’t know where I’ve gone wrong. Please help, I’m SO confused! Here are the variables I’m using:
This would be the way . Just as a minor addition, we need to remember to use trailing parentheses in C# projects in method calls without parameters, so it needs to be x.ToString().
Thank you so much for your help! I changed the assign on the left (in the 'For Each Row in Data Table activity) to: Out_Config[CurrentRow[“Name”].ToString()] and it worked perfectly! Thank you!