How to add a list or several values for one key in web.config?
For example: I have a key called "xyz", it has a list of values, that is, val1, val2, val3, etc.
And this can be obtained in my code, as other keys are available.
Add to web configuration as comma separated
<add key = "xyz" value="val1, val2, val3"/>
access them as
string[] xyzValues = System.Configuration.ConfigurationManager.AppSettings["xyz"].Split(",");
You cannot do this directly, but with a bit more encoding, you may have a custom configuration section in your configuration files. The https://msdn.microsoft.com/en-us/library/2tw134k3.aspx link describes how to perform custom configuration.
Another way could be to use a separator in a value and define multiple values, and then use those values using the split function (as mentioned above)
Define the delimiter character.
Then set the application parameter by its key and use string.Split to get these several values as an array or IEnumerable<string> :
string.Split
IEnumerable<string>
IEnumerable<string> values = ConfigurationManager.AppSettings["xyz"].Split(',');
You can use the appsettings tag
<appSettings> <add key="xyz" value="val1;val2;val3" /> </appSettings>
C # code
string[] values = ConfigurationManager.AppSettings["xyz"].Split(';');
Source: https://habr.com/ru/post/1232090/More articles:How to configure multiple jersey provider packages using javax dynamic servlet registration - javaEstablish many-to-many relationships - python-2.7what the endpoint.ex file does in phoenix elixir - elixirAndroid emulator always with 533 MB of internal memory - androidC ++ Elegant way to implement assignment of various types using one method and without warning? - c ++No axis shown on Xcode 7 playground - swiftGo: How to start a browser AFTER the server starts listening? - httpToo many constructor characters - c ++data.table: = assignments when the variable has the same name as the column - rlsof column FD is DEL, what does this mean? - unixAll Articles