【发布时间】:2010-09-06 07:32:35
【问题描述】:
在需要认真重构的桌面应用程序中,我有几块如下所示的代码:
private void LoadSettings()
{
WindowState = Properties.Settings.Default.WindowState;
Location = Properties.Settings.Default.WindowLocation;
...
}
private void SaveSettings()
{
Properties.Settings.Default.WindowState = WindowState;
Properties.Settings.Default.WindowLocation = Location;
...
}
替换它的最佳方法是什么?项目施加的限制:
- Visual Studio 2005
- C#/.NET 2.0
- Windows 窗体
更新
对于后人,我还发现了两个有用的教程:"Windows Forms User Settings in C#" 和 "Exploring Secrets of Persistent Application Settings"。
我问了一个关于使用这种技术绑定表单大小here 的后续问题。我将它们分开来帮助搜索类似问题的人。
【问题讨论】: