开发者

Settings file instance name

When I create a settings file, Visual Studio generates a singleton with the instance name Default:

Properties.Settings.Default.SettingIHaveSaved

How can I get Visual Studio to generate another list of settings with a new instance name? Say,

开发者_如何学运维
Properties.Settings.Debug.SettingIHaveSaved

Thanks!


You can't get Visual Studio to generate this property but you can easily add this behavior. Settings is implemented as a partial class so you just need to create a new file with another partial declaration and add the property you want there.

For example

internal partial class Settings {
  private static Settings _debugInstance = ApplicationSettingsBase.Synchronized(new Settings());
  internal static Settings Debug { 
    get { return _debugInstance; }
  }
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜