How do I store an array of a particular type into my settings file?
Posted
by joebeazelman
on Stack Overflow
See other posts from Stack Overflow
or by joebeazelman
Published on 2010-05-03T23:41:30Z
Indexed on
2010/05/03
23:48 UTC
Read the original article
Hit count: 461
For some reason, I can't seem to store an array of my class into the settings. Here's the code:
var newLink = new Link();
Properties.Settings.Default.Links = new ArrayList();
Properties.Settings.Default.Links.Add(newLink);
Properties.Settings.Default.Save();
In my Settings.Designer.cs I specified the field to be an array list:
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
public global::System.Collections.ArrayList Links {
get {
return ((global::System.Collections.ArrayList)(this["Links"]));
}
set {
this["Links"] = value;
}
}
For some reason, it won't save any of the data even though the Link class is serializable and I've tested it.
© Stack Overflow or respective owner