Bra*_*don 18 c# programming-languages
我有以下代码:
foreach (SettingsProperty currentProperty in Properties.Settings.Default.Properties)
{
if (Double.TryParse(GenerateValue()), out result))
{
currentProperty.DefaultValue = result.ToString();
Properties.Settings.Default.Save();
}
}
Run Code Online (Sandbox Code Playgroud)
它从mysql数据库中获取新值.如果我添加一个MessageBox.Show来显示新值,它似乎工作正常但它实际上并没有保存它.我认为这是因为我将值赋给变量......有没有办法做到这一点?
Properties.Settings.Default.IndexOf(currentProperty.name).DefaultValue = result
Run Code Online (Sandbox Code Playgroud)
Ale*_*Aza 28
这可能有效:
foreach (SettingsProperty currentProperty in Properties.Settings.Default.Properties)
{
Properties.Settings.Default[currentProperty.Name] = result.ToString();
Properties.Settings.Default.Save();
}
Run Code Online (Sandbox Code Playgroud)
请记住,属性应具有"用户"范围才能保存.
| 归档时间: |
|
| 查看次数: |
19790 次 |
| 最近记录: |