app.config multiple values by single key [duplicate]

我怕爱的太早我们不能终老 提交于 2019-12-18 18:51:32

问题


is it possible to have app.config file like this :

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <appSettings>
    <add key="someKey" value="valueHere"/>
    <add key="anotherKey" value="valueHere"/>
    <add key="listOfValues">
        <value1/>
        ...
        <valueN/>
    </add>
  </appSettings>
</configuration>

I mean, I want to have a key in config file that returns a list of values.How to do it? Think it's pretty easy, but I just can't find any examples

UPD : maybe I should put multiple values separated by semicolon and then just split them?.. But I think it is not very good idea...


回答1:


I don't think the standard key/value pair config settings can do it, but with a little more coding you can have all the configuration XML goodness you want with a custom config section.




回答2:


Don't know if what you're asking is possible. But what I do is I concatenate values using a separator like ";" for instance.

So you have something like:

<add key="runningDays" value="Mon;Tue;Wed;Thu;Fri"/>

Then I split the value string from config using the separator to get the list of possible values for the given key.



来源:https://stackoverflow.com/questions/4992096/app-config-multiple-values-by-single-key

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!