Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add array to key in web.config

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?

like image 305
user1269625 Avatar asked Jul 30 '12 19:07

user1269625


1 Answers

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]" /> 
like image 60
Matthew Avatar answered Oct 04 '22 03:10

Matthew