32

I was wondering if its possible to put an array as a value in a key...example

<add key="email" value="emails["[email protected], [email protected]"] />

Would that syntax work?

1
  • 1
    If you are only needing a list of values you can just use a delimiter of your choosing (that is legal in XML, etc.) and split the value when you need to. Commented Jul 30, 2012 at 19:48

1 Answer 1

69

With ConfigurationManager.AppSettings you can only retrieve scalar values. For your example, if you seperate your emails with a semicolon, you can do:

string[] emails = ConfigurationManager.AppSettings["email"].Split(';');

with the web.config

<add key="email" value="[email protected];[email protected]" />
Sign up to request clarification or add additional context in comments.

1 Comment

brilliant answer :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.