C# 如何在数组中存储用户设置值?
我像这样存储值,但我想使用数组存储这些值,并想在打开程序时加载这些值C# 如何在数组中存储用户设置值?,c#,arrays,application-settings,C#,Arrays,Application Settings,我像这样存储值,但我想使用数组存储这些值,并想在打开程序时加载这些值 private void Button1_Click(object sender, EventArgs e) { Properties.Settings.Default.VibratorValue1 = vibrator_numericUpDown1.Text; Properties.Settings.Default.VibratorValue2 = vibrator_numericUpDown2.Text;
private void Button1_Click(object sender, EventArgs e)
{
Properties.Settings.Default.VibratorValue1 = vibrator_numericUpDown1.Text;
Properties.Settings.Default.VibratorValue2 = vibrator_numericUpDown2.Text;
Properties.Settings.Default.VibratorValue3 = vibrator_numericUpDown3.Text;
Properties.Settings.Default.VibratorValue4 = vibrator_numericUpDown4.Text;
Properties.Settings.Default.Save();
}
private void Panel1_load(object sender, PaintEventArgs e)
{
vib_numericUpDown1.Text = Properties.Settings.Default.VibValue1;
vib_numericUpDown2.Text = Properties.Settings.Default.VibValue2;
vib_numericUpDown3.Text = Properties.Settings.Default.VibValue3;
vib_numericUpDown4.Text = Properties.Settings.Default.VibValue4;
}
这回答了你的问题吗?我试过了,但没用。加载时出错。文本值是否只是“不起作用”,或者是否存在异常、中断或部分输出等。?遵循所选答案中的步骤对我有效。在experience.exe中发生了类型为“System.NullReferenceException”的异常,但未在用户代码中处理。您需要初始化数组一次(使用设置设计器将默认值放入其中)。