每次启动应用程序时,首次加载自定义设置大约需要2秒。
有没有办法加速呢?
(或者这被广泛使用,as suggested here,尽管有速度惩罚。)
以下是代码:
public class MySettings : ApplicationSettingsBase
{
[UserScopedSettingAttribute()]
public int MyInt
{
get { return (int)(this["MyInt"]); }
set { this["MyInt"] = value; }
}
}
并且这样称呼:
MySettings s = new MySettings();
int i = s.MyInt;