app.config 单键多个值
是否可以有这样的 app.config 文件:
<?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>
我的意思是,我想在配置文件中有一个返回值列表的键。如何做到这一点? 认为这很简单,但我只是找不到任何示例
UPD :也许我应该用分号分隔多个值,然后将它们分开?...但我认为这不是一个好主意...
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...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我不认为标准的键/值对配置设置可以做到这一点,但是通过更多的编码,您可以通过 自定义配置部分。
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:
Then I split the value string from config using the separator to get the list of possible values for the given key.