Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multiple values for a single config key

I'm trying to use ConfigurationManager.AppSettings.GetValues() to retrieve multiple configuration values for a single key, but I'm always receiving an array of only the last value. My appsettings.config looks like

<add key="mykey" value="A"/> <add key="mykey" value="B"/> <add key="mykey" value="C"/> 

and I'm trying to access with

ConfigurationManager.AppSettings.GetValues("mykey"); 

but I'm only getting { "C" }.

Any ideas on how to solve this?

like image 380
Daniel Schierbeck Avatar asked May 12 '10 14:05

Daniel Schierbeck


1 Answers

Try

<add key="mykey" value="A,B,C"/> 

And

string[] mykey = ConfigurationManager.AppSettings["mykey"].Split(','); 
like image 169
Joel Avatar answered Sep 21 '22 13:09

Joel