filling arrays from config.app values

  • Thread starter Thread starter Eric Cathell
  • Start date Start date
E

Eric Cathell

I have an integer array that I want to fill from my config.app file...


i have this setup

dim myArray() as integer=appsettings.GetValue("myArray",
GetType(System.int32))


my configuration is set as follows
<add key="myArray" value="{6,7,15}" />





however i get an error saying the value is not an integer type....however if
i comment out my appsettings and put my values in curly braces on the line
it works fine...



any suggestions on how to do this?



Eric
 
Hi Eric,

It's a bit of an effort but..
Read the values as a string,
Remove the brackets.
Split it into an array of strings with Split (",")
Finally, convert each value to an Integer using Parse (or Val).

Regards,
Fergus
 
* "Eric Cathell said:
I have an integer array that I want to fill from my config.app file...

Notice that the config file should _not_ be used to save preferences...
 
Back
Top