Store String Array In appSettings?
You could use the AppSettings with a System.Collections.Specialized.StringCollection
.
var myStringCollection = Properties.Settings.Default.MyCollection;foreach (String value in myStringCollection){ // do something}
Each value is separated by a new line.
Here's a screenshot (german IDE but it might be helpful anyway)
For strings it is easy, simply add the following to your web.config
file:
<add key="myStringArray" value="fred,Jim,Alan" />
and then you can retrieve the value into an array as follows:
var myArray = ConfigurationManager.AppSettings["myStringArray"].Split(',');
For integers I found the following way quicker.
First of all create a appSettings key with integer values separated by commas in your app.config.
<add key="myIntArray" value="1,2,3,4" />
Then split and convert the values into int array by using LINQ
int[] myIntArray = ConfigurationManager.AppSettings["myIntArray"].Split(',').Select(n => Convert.ToInt32(n)).ToArray();