Using HashSet <T> in C # Properties.Settings
I am creating some C # tools for a game I am working on and adding a "Recent files->" dropdown menu.
The problem is I can't get the C # Settings page in VS2008 so I can add a typed HashSet. There is simply no way to do it.
I got all the freebies and manually edited the Settings.Designer.cs file:
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
public global::System.Collections.Generic.HashSet<String> RecentLibs {
get {
return ((global::System.Collections.Generic.HashSet<String>)(this["RecentLibs"]));
}
set {
this["RecentLibs"] = value;
}
}
Everything seems to work fine. However, I know that at some point it is going to destroy those changes with a code generator.
What's the correct way to do this? Does C # have some kind of built-in type that I should be using for this function and not just a HashSet?
a source to share
Don't do it like that. VS will destroy any code in Settings.Designer.cs.
Instead, open the settings editor from VS (this will display the Design editor for the Settings.settings and Settings.Designer.cs file).
Then press F7 to get a code view. VS will automatically create a file named Settings.cs, which is a partial class shared with the Settings.Designer.cs file. This file you can edit in your heart content.
However, your XML entries in the Settings.settings file might get fried. I would keep a separate copy of these just in case.
a source to share