开发者

app.config multiple values by single key [duplicate]

This question already has answers here: Multiple values for a single config key (10 answers) Closed 9 years ago.

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 : may开发者_如何转开发be I should put multiple values separated by semicolon and then just split them?.. But I think it is not very good idea...


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜