I'm creating an application that will look AppSettings, pull those keys and their values up into a DataTable, use the DataTable to edit or add keys, check for duplicate keys once edited, and save them back to into AppSettings
. I currently have three buttons.
One is ProgrammedBy
which pulls up a separate data table, a View App Settings within App.config and display it on a data table, and finally an Update Settings button that checks for duplicate keys after the information is entered on the DataTable then save the keys and their values back to AppSettings:
Here is a list of the keys and values within in the App.config file. Note I have given a key a duplicate name:
I'm using a nested for loop on the part where it checks for duplicate keys. The System.Collection library only checks the last duplicate key. It totally ignores the first one. When I drill down or hover my mouse over the items variable, Rows/Results View, within Visual Studio it only shows me a 5 key pair. There is obviously a 6th pair as seen above. Here is that for loop and for the purpose of debugging I have put a break point past the end of the for loop:
I need it to be able to throw an exception error when it finds the duplicate key. If at all possible throw the exception error message and highlight what that duplicate key is. Also if possible make the System.Collection library not skip the duplicate key or ignore the duplicate key.