Reputation: 3256
I have follwing in app.config file:
<appSettings>
<add key="Name" value="Office"/>
...
<add key="Name" value="HotSpot"/>
...
<add key="Name" value="Home"/>
</appSettings>
I tried
ConfigurationManager.AppSettings["Name"]
But it only gives me one Value? How can i get list of all values? I am using c# 3.5. Is there lambda expression or something i can use to get that?
Upvotes: 2
Views: 6864
Reputation: 102723
You can only use one key per value, so this approach will not work.
There are two alternate approaches I can think of:
Use a single key with a delimiter, and retrieve with ConfigurationManager.AppSettings["Name"].Split(new [] { "," });
.
<add key="Name" value="Office,Hotspot,Home" />
Use a custom section to create a section that can contain your array of strings.
Upvotes: 7