You will have to start by creating a setting in your project settings file, let's name it CustomClasses
. The next part is a little bit tricky, as it involves editing the XML of the Settings.settings file:
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings"
CurrentProfile="(Default)"
GeneratedClassNamespace="ConsoleApplication1.Properties"
GeneratedClassName="Settings">
<Profiles />
<Settings>
<Setting Name="CustomClasses"
GenerateDefaultValueInCode="false"
Type="System.Collections.Generic.List<ConsoleApplication1.CustomClass>"
Scope="User">
</Setting>
</Settings>
</SettingsFile>
If you open your Settings.Designer.cs file, you should have now:
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
public global::System.Collections.Generic
.List<ConsoleApplication1.CustomClass> CustomClasses {
get {
return ((global::System.Collections.Generic
.List<ConsoleApplication1.CustomClass>)(this["CustomClasses"]));
}
set {
this["CustomClasses"] = value;
}
}
You can save the setting in your application:
class Program
{
static void Main(string[] args)
{
Properties.Settings.Default.CustomClasses = new List<CustomClass>() {
new CustomClass(){Columns="columns1"},
new CustomClass(){Columns="columns2"},
new CustomClass(){Columns="columns3"},
new CustomClass(){Columns="columns4"}
};
Properties.Settings.Default.Save();
}
}