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?
Try
<add key="mykey" value="A,B,C"/>
And
string[] mykey = ConfigurationManager.AppSettings["mykey"].Split(',');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With