Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/273.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何在数组中存储用户设置值?_C#_Arrays_Application Settings - Fatal编程技术网

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”的异常,但未在用户代码中处理。您需要初始化数组一次(使用设置设计器将默认值放入其中)。